diff --git a/storage/cf/rs/ecr-188-A.rs b/storage/cf/rs/ecr-188-A.rs new file mode 100644 index 0000000..3e40555 --- /dev/null +++ b/storage/cf/rs/ecr-188-A.rs @@ -0,0 +1,28 @@ +use std::io::stdin; + +fn main() { + let mut line = String::new(); + stdin().read_line(&mut line).unwrap(); + + let t = line.trim().parse::().unwrap(); + + (0..t).for_each(|_| { + line.clear(); + stdin().read_line(&mut line).unwrap(); + + let n = line.trim().parse::().unwrap(); + line.clear(); + stdin().read_line(&mut line).unwrap(); + let arr = line.trim().chars().collect::>(); + + let mut res = 0; + for (i, &st) in arr.iter().enumerate() { + if st == 'L' { + res = i + 1; + break; + } + } + + println!("{}", res); + }); +} diff --git a/storage/cf/rs/ecr-188-B.rs b/storage/cf/rs/ecr-188-B.rs new file mode 100644 index 0000000..b6948db --- /dev/null +++ b/storage/cf/rs/ecr-188-B.rs @@ -0,0 +1,26 @@ +use std::io::{read_to_string, stdin}; + +fn main() { + let temp = read_to_string(stdin()).unwrap(); + let mut iter = temp + .split_ascii_whitespace() + .map(|x| x.parse::().unwrap()); + + let t = iter.next().unwrap(); + + (0..t).for_each(|_| { + let n = iter.next().unwrap(); + let arr = (0..n).map(|_| iter.next().unwrap()).collect::>(); + let mut cnt = 0; + let mut before_most = 0; + for i in 0..n { + if arr[i] > before_most { + cnt += 1; + before_most = arr[i]; + } else if arr[i] == before_most { + cnt += 1; + } + } + println!("{}", cnt); + }); +} diff --git a/storage/cf/rs/ecr-188-C.rs b/storage/cf/rs/ecr-188-C.rs new file mode 100644 index 0000000..0cb2697 --- /dev/null +++ b/storage/cf/rs/ecr-188-C.rs @@ -0,0 +1,94 @@ +use std::io::{read_to_string, stdin}; + +fn gcd(a: usize, b: usize) -> usize { + if b == 0 { a } else { gcd(b, a % b) } +} + +fn lcm(a: usize, b: usize) -> usize { + a * b / gcd(a, b) +} + +fn main() { + let temp = read_to_string(stdin()).unwrap(); + let mut iter = temp + .split_ascii_whitespace() + .map(|x| x.parse::().unwrap()); + + let t = iter.next().unwrap(); + (0..t).for_each(|_| { + let (a, b, c, m) = ( + iter.next().unwrap(), + iter.next().unwrap(), + iter.next().unwrap(), + iter.next().unwrap(), + ); + + let l_ab = lcm(a, b); + let l_bc = lcm(b, c); + let l_ac = lcm(a, c); + let l_abc = lcm(l_ab, c); + // density of a + + let cnt_a = { + let tot = m / a; + if tot == 0 { + tot + } else { + let with_b = l_ab / a; + let with_c = l_ac / a; + let with_bc = l_abc / a; + let tot_with_b = tot / with_b; + let tot_with_c = tot / with_c; + let tot_with_bc = tot / with_bc; + + let res = (tot + tot_with_bc - tot_with_b - tot_with_c) * 6 + + (tot_with_b - tot_with_bc) * 3 + + (tot_with_c - tot_with_bc) * 3 + + (tot_with_bc) * 2; + res + } + }; + + let cnt_b = { + let tot = m / b; + if tot == 0 { + tot + } else { + let with_a = l_ab / b; + let with_c = l_bc / b; + let with_ac = l_abc / b; + let tot_with_a = tot / with_a; + let tot_with_c = tot / with_c; + let tot_with_ac = tot / with_ac; + + let res = (tot + tot_with_ac - tot_with_a - tot_with_c) * 6 + + (tot_with_a - tot_with_ac) * 3 + + (tot_with_c - tot_with_ac) * 3 + + (tot_with_ac) * 2; + res + } + }; + + let cnt_c = { + let tot = m / c; + if tot == 0 { + tot + } else { + let with_a = l_ac / c; + let with_b = l_bc / c; + let with_ab = l_abc / c; + let tot_with_a = tot / with_a; + let tot_with_b = tot / with_b; + let tot_with_ab = tot / with_ab; + + let res = (tot + tot_with_ab - tot_with_a - tot_with_b) * 6 + + (tot_with_a - tot_with_ab) * 3 + + (tot_with_b - tot_with_ab) * 3 + + (tot_with_ab) * 2; + res + } + }; + + println!("{} {} {}", cnt_a, cnt_b, cnt_c); + }) +} diff --git a/storage/cf/rs/ecr-188-D.rs b/storage/cf/rs/ecr-188-D.rs new file mode 100644 index 0000000..20eed82 --- /dev/null +++ b/storage/cf/rs/ecr-188-D.rs @@ -0,0 +1,36 @@ +use std::io::{read_to_string, stdin}; + +fn main() { + let temp = read_to_string(stdin()).unwrap(); + let mut iter = temp + .split_ascii_whitespace() + .map(|x| x.parse::().unwrap()); + + let t = iter.next().unwrap(); + (0..t).for_each(|_| { + let (n, m) = (iter.next().unwrap(), iter.next().unwrap()); + let mut res = 0; + if m == 0 { + res = n; + } else { + let mut edges = vec![vec![]; n]; + let mut vis = vec![false; n]; + for _ in 0..m { + let (u, v) = (iter.next().unwrap() - 1, iter.next().unwrap() - 1); + edges[u].push(v); + edges[v].push(u); + } + + let mut deq = vec![]; + for i in 0..n { + deq.push(i); + } + + while !deq.is_empty() { + let () + } + + + } + }); +} diff --git a/storage/cf/rs/ecr-188-E.rs b/storage/cf/rs/ecr-188-E.rs new file mode 100644 index 0000000..801281c --- /dev/null +++ b/storage/cf/rs/ecr-188-E.rs @@ -0,0 +1,19 @@ +use std::io::{read_to_string, stdin}; + +fn conv(s: &str) -> Vec { + let mut v = vec![0; 10]; + for ch in s.chars() { + v[(ch as usize - '0' as usize) as usize] += 1; + } + v +} + +fn main() { + let temp = read_to_string(stdin()).unwrap(); + let mut iter = temp.split_ascii_whitespace(); + + (0..iter.next().unwrap().parse::().unwrap()).for_each(|_| { + let s = iter.next().unwrap().trim(); + let cnts = conv(s); + }) +}