Skip to content

Commit

Permalink
Add atcoder/joi2025yo1a/a.rs atcoder/joi2025yo1a/b.rs atcoder/joi2025…
Browse files Browse the repository at this point in the history
…yo1a/c.rs atcoder/joi2025yo1a/d.rs
  • Loading branch information
koba-e964 committed Dec 15, 2024
1 parent 88a9abe commit ff05a6c
Show file tree
Hide file tree
Showing 4 changed files with 88 additions and 0 deletions.
10 changes: 10 additions & 0 deletions atcoder/joi2025yo1a/a.rs
Original file line number Diff line number Diff line change
@@ -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);
}
14 changes: 14 additions & 0 deletions atcoder/joi2025yo1a/b.rs
Original file line number Diff line number Diff line change
@@ -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}");
}
19 changes: 19 additions & 0 deletions atcoder/joi2025yo1a/c.rs
Original file line number Diff line number Diff line change
@@ -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}");
}
45 changes: 45 additions & 0 deletions atcoder/joi2025yo1a/d.rs
Original file line number Diff line number Diff line change
@@ -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::<Vec<_>>()
};
($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}");
}

0 comments on commit ff05a6c

Please sign in to comment.