add cf ecr-188 ABCDE
This commit is contained in:
28
storage/cf/rs/ecr-188-A.rs
Normal file
28
storage/cf/rs/ecr-188-A.rs
Normal file
@@ -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::<usize>().unwrap();
|
||||||
|
|
||||||
|
(0..t).for_each(|_| {
|
||||||
|
line.clear();
|
||||||
|
stdin().read_line(&mut line).unwrap();
|
||||||
|
|
||||||
|
let n = line.trim().parse::<usize>().unwrap();
|
||||||
|
line.clear();
|
||||||
|
stdin().read_line(&mut line).unwrap();
|
||||||
|
let arr = line.trim().chars().collect::<Vec<_>>();
|
||||||
|
|
||||||
|
let mut res = 0;
|
||||||
|
for (i, &st) in arr.iter().enumerate() {
|
||||||
|
if st == 'L' {
|
||||||
|
res = i + 1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
println!("{}", res);
|
||||||
|
});
|
||||||
|
}
|
||||||
26
storage/cf/rs/ecr-188-B.rs
Normal file
26
storage/cf/rs/ecr-188-B.rs
Normal file
@@ -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::<usize>().unwrap());
|
||||||
|
|
||||||
|
let t = iter.next().unwrap();
|
||||||
|
|
||||||
|
(0..t).for_each(|_| {
|
||||||
|
let n = iter.next().unwrap();
|
||||||
|
let arr = (0..n).map(|_| iter.next().unwrap()).collect::<Vec<_>>();
|
||||||
|
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);
|
||||||
|
});
|
||||||
|
}
|
||||||
94
storage/cf/rs/ecr-188-C.rs
Normal file
94
storage/cf/rs/ecr-188-C.rs
Normal file
@@ -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::<usize>().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);
|
||||||
|
})
|
||||||
|
}
|
||||||
36
storage/cf/rs/ecr-188-D.rs
Normal file
36
storage/cf/rs/ecr-188-D.rs
Normal file
@@ -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::<usize>().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 ()
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
19
storage/cf/rs/ecr-188-E.rs
Normal file
19
storage/cf/rs/ecr-188-E.rs
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
use std::io::{read_to_string, stdin};
|
||||||
|
|
||||||
|
fn conv(s: &str) -> Vec<usize> {
|
||||||
|
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::<usize>().unwrap()).for_each(|_| {
|
||||||
|
let s = iter.next().unwrap().trim();
|
||||||
|
let cnts = conv(s);
|
||||||
|
})
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user