C++
pending
Rust
A
1fn main()
2{
3 loop {
4 let mut s = String::new();
5 std::io::stdin().read_line(&mut s);
6
7 let mut two = s.split_whitespace().map(|s| s.parse::<i32>());
8 match (two.next(), two.next()) {
9 (Some(Ok(n)), Some(Ok(m))) => {
10 if 2 * n > m || 4 * n < m || m % 2 != 0 {
11 println!("False!");
12 } else {
13 let y = (m - 2 * n) / 2;
14 let x = n - y;
15 println!("{} {}", x, y);
16 }
17 },
18 _ => {
19 break;
20 },
21 }
22 }
23}
B
1fn main() {
2 let mut ts = String::new();
3 std::io::stdin().read_line(&mut ts);
4 if let Ok(t) = ts.trim().parse::<i32>() {
5 for _ in 0..t {
6 let mut ns = String::new();
7 std::io::stdin().read_line(&mut ns);
8 if let Ok(a) = ns.trim().parse::<i32>() {
9 if a == 0 || a == 1 {
10 println!("No");
11 continue;
12 }
13 let mut is_prime = true;
14 for factor in 2..a/2+1 {
15 if a % factor == 0 {
16 is_prime = false;
17 break;
18 }
19 }
20 println!("{}", if is_prime { "Yes" } else { "No" });
21 }
22 }
23 }
24}
C
1fn dfs(v: &[i32], m: i32, sum: i32, cnt: i32) -> bool {
2 if cnt == 4 {
3 if sum == m {
4 return true;
5 } else {
6 return false;
7 }
8 }
9 let mut ret = false;
10 for a in v {
11 if sum + a <= m {
12 ret |= dfs(v, m, sum + a, cnt + 1);
13 }
14 if ret {
15 break;
16 }
17 }
18 return ret;
19}
20
21fn main() {
22 let mut s1 = String::new();
23 std::io::stdin().read_line(&mut s1);
24 let n = s1.trim().parse::<i32>().unwrap();
25
26 let mut s2 = String::new();
27 std::io::stdin().read_line(&mut s2);
28 let m = s2.trim().parse::<i32>().unwrap();
29
30 let mut s3 = String::new();
31 std::io::stdin().read_line(&mut s3);
32 let v: Vec<i32> = s3.trim().split_whitespace().map(|s| s.parse::<i32>().unwrap()).collect();
33
34 if dfs(&v, m, 0, 0) {
35 println!("Yes");
36 } else {
37 println!("No");
38 }
39}
F
1fn main() {
2 let mut ts = String::new();
3 std::io::stdin().read_line(&mut ts);
4
5 let mut arr_s = String::new();
6 std::io::stdin().read_line(&mut arr_s);
7 let mut arr = arr_s.trim().split_whitespace().map(|s| s.parse::<i32>());
8 let mut vec = Vec::new();
9 while let Some(Ok(a)) = arr.next() {
10 vec.push(a);
11 }
12 &vec.sort();
13
14 for i in 0..vec.len() {
15 if i != 0 {
16 print!(" ");
17 }
18 print!("{}", vec[i]);
19 }
20 println!();
21}
G
1fn main() {
2 let mut s = String::new();
3 std::io::stdin().read_line(&mut s);
4 let mut si = s.trim().split_whitespace().map(|s| s.parse::<i32>().unwrap());
5 let n = si.next().unwrap();
6 let m = si.next().unwrap();
7 let mut intervals: Vec<(i32, i32)> = Vec::new();
8 for _ in 0..m {
9 let mut s = String::new();
10 std::io::stdin().read_line(&mut s);
11 let mut si = s.trim().split_whitespace().map(|s| s.parse::<i32>().unwrap());
12 intervals.push((si.next().unwrap(), si.next().unwrap()));
13 }
14
15 let mut s = String::new();
16 std::io::stdin().read_line(&mut s);
17 let f = s.trim().parse::<i32>().unwrap();
18
19 let mut r = false;
20 for v in intervals {
21 if v.0 <= f && f <= v.1 {
22 r = true;
23 break;
24 }
25 }
26 println!("{}", if r { "Yes" } else { "No" });
27}
H
1fn gcd(a: u64, b: u64) -> u64 {
2 if b == 0 {
3 a
4 } else {
5 gcd(b, a % b)
6 }
7}
8
9fn main() {
10 let mut s = String::new();
11 std::io::stdin().read_line(&mut s);
12 let w: Vec<u64> = s.trim().split_whitespace().map(|s| s.parse::<u64>().unwrap()).collect();
13 println!("{}", w[0] / gcd(w[0], w[1]) * w[1]);
14}
I
1fn main() {
2 let mut t = String::new();
3 std::io::stdin().read_line(&mut t);
4 let mut cnt = [0; 11];
5
6 loop {
7 let mut ns = String::new();
8 let res = std::io::stdin().read_line(&mut ns);
9 let mut itr = ns.trim().split_whitespace().map(|s| s.parse::<i32>().unwrap());
10 let mut at_least = 0;
11 while let Some(a) = itr.next() {
12 cnt[a as usize] += 1;
13 at_least += 1;
14 }
15 if at_least == 0 {
16 break;
17 }
18 }
19
20 for i in 1usize..11usize {
21 println!("{}", cnt[i]);
22 }
23}
L
1fn main() {
2 let mut s = String::new();
3 std::io::stdin().read_line(&mut s);
4 let mut w = s.trim().split_whitespace().map(|s| s.parse::<i32>().unwrap()).collect::<Vec<i32>>();
5
6 let mut a: Vec<Vec<i32>> = Vec::new();
7 for _ in 0..w[0] {
8 let mut line = String::new();
9 std::io::stdin().read_line(&mut line);
10 a.push(line.trim().split_whitespace().map(|s| s.parse::<i32>().unwrap()).collect::<Vec<i32>>());
11 }
12
13 for i in 0usize..w[0] as usize {
14 let mut line = String::new();
15 std::io::stdin().read_line(&mut line);
16 let mut it = line.trim().split_whitespace().map(|s| s.parse::<i32>().unwrap());
17 if w[0] == w[2] && w[1] == w[3] {
18 for j in 0usize..w[1] as usize {
19 if j != 0 {
20 print!(" ");
21 }
22 print!("{}", a[i][j] + it.next().unwrap());
23 }
24 println!();
25 }
26 }
27
28 if w[0] != w[2] || w[1] != w[3] {
29 println!("False!");
30 return;
31 }
32}
M
1fn main() {
2 let mut s = String::new();
3 std::io::stdin().read_line(&mut s);
4 let n = s.trim().parse::<i32>().unwrap();
5 let mut v = Vec::new();
6
7 let mut avg = 0f64;
8 let mut s = String::new();
9 std::io::stdin().read_line(&mut s);
10 let mut it = s.trim().split_whitespace().map(|s| s.parse::<i32>().unwrap());
11 while let Some(a) = it.next() {
12 avg += a as f64;
13 v.push(a);
14 }
15
16 avg /= n as f64;
17 println!("{:.2}", avg);
18
19 let mut first_one = true;
20 for a in v {
21 if a as f64 >= avg {
22 if first_one {
23 first_one = false;
24 } else {
25 print!(" ");
26 }
27 print!("{}", a);
28 }
29 }
30}
N
1fn main() {
2 let mut s = String::new();
3 std::io::stdin().read_line(&mut s);
4 let mut s = String::new();
5 std::io::stdin().read_line(&mut s);
6 let mut it = s.trim().split_whitespace().map(|s| s.parse::<i32>().unwrap());
7 let mut v: Vec<i32> = Vec::new();
8
9 let mut first = true;
10 while let Some(a) = it.next() {
11 if first {
12 first = false;
13 } else {
14 print!(" ");
15 }
16 let mut cnt: i32 = 0;
17 for k in &v {
18 if k < &a {
19 cnt += 1;
20 }
21 }
22 print!("{}", cnt);
23 v.push(a);
24 }
25}
R
1fn main() {
2 let mut s = String::new();
3 std::io::stdin().read_line(&mut s);
4 let mut a = s.trim().parse::<i32>().unwrap();
5 if a == 0 {
6 println!("0");
7 return;
8 }
9
10 let mut first_in = true;
11 while a != 0 {
12 if first_in {
13 first_in = false;
14 } else {
15 print!(" ");
16 }
17
18 print!("{}", a % 10);
19 a /= 10;
20 }
21}