diff --git a/atcoder/joi2025yo1a/a.rs b/atcoder/joi2025yo1a/a.rs new file mode 100644 index 00000000..76c0c5af --- /dev/null +++ b/atcoder/joi2025yo1a/a.rs @@ -0,0 +1,10 @@ +fn getline() -> String { + let mut ret = String::new(); + std::io::stdin().read_line(&mut ret).ok().unwrap(); + ret +} + +fn main() { + let a: i32 = getline().trim().parse().unwrap(); + println!("{}", a / 5); +} diff --git a/atcoder/joi2025yo1a/b.rs b/atcoder/joi2025yo1a/b.rs new file mode 100644 index 00000000..5f053a73 --- /dev/null +++ b/atcoder/joi2025yo1a/b.rs @@ -0,0 +1,14 @@ +fn getline() -> String { + let mut ret = String::new(); + std::io::stdin().read_line(&mut ret).ok().unwrap(); + ret +} + +fn main() { + let x: i32 = getline().trim().parse().unwrap(); + let mut s = x / 2; + if x % 2 == 1 { + s += 3; + } + println!("{s}"); +} diff --git a/atcoder/joi2025yo1a/c.rs b/atcoder/joi2025yo1a/c.rs new file mode 100644 index 00000000..5a610897 --- /dev/null +++ b/atcoder/joi2025yo1a/c.rs @@ -0,0 +1,19 @@ +fn getline() -> String { + let mut ret = String::new(); + std::io::stdin().read_line(&mut ret).ok().unwrap(); + ret +} + +fn main() { + getline(); + let mut s = String::new(); + for c in getline().trim().chars() { + s.push(match c { + 'J' => 'O', + 'O' => 'I', + 'I' => 'J', + _ => panic!(), + }); + } + println!("{s}"); +} diff --git a/atcoder/joi2025yo1a/d.rs b/atcoder/joi2025yo1a/d.rs new file mode 100644 index 00000000..9bd1ef6f --- /dev/null +++ b/atcoder/joi2025yo1a/d.rs @@ -0,0 +1,45 @@ +// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8 +macro_rules! input { + ($($r:tt)*) => { + let stdin = std::io::stdin(); + let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock())); + let mut next = move || -> String{ + bytes.by_ref().map(|r|r.unwrap() as char) + .skip_while(|c|c.is_whitespace()) + .take_while(|c|!c.is_whitespace()) + .collect() + }; + input_inner!{next, $($r)*} + }; +} + +macro_rules! input_inner { + ($next:expr) => {}; + ($next:expr,) => {}; + ($next:expr, $var:ident : $t:tt $($r:tt)*) => { + let $var = read_value!($next, $t); + input_inner!{$next $($r)*} + }; +} + +macro_rules! read_value { + ($next:expr, [ $t:tt ; $len:expr ]) => { + (0..$len).map(|_| read_value!($next, $t)).collect::>() + }; + ($next:expr, $t:ty) => ($next().parse::<$t>().expect("Parse error")); +} + +fn main() { + input! { + n: usize, m: usize, + a: [i32; n], + b: [i32; m], + } + let mut s = 0; + for i in 0..n { + for j in 0..m { + s += (a[i] + b[j]) * a[i].max(b[j]); + } + } + println!("{s}"); +}