solutions: 25A
This commit is contained in:
parent
5a7efc488e
commit
0180a76ed4
2 changed files with 28 additions and 0 deletions
|
@ -61,5 +61,6 @@ My set of solutions to the problems on Code Forces.
|
||||||
- [58A Chat room](https://codeforces.com/problemset/problem/58/A)
|
- [58A Chat room](https://codeforces.com/problemset/problem/58/A)
|
||||||
- [43A Football](https://codeforces.com/problemset/problem/43/A)
|
- [43A Football](https://codeforces.com/problemset/problem/43/A)
|
||||||
- [34B Sale](https://codeforces.com/problemset/problem/34/B)
|
- [34B Sale](https://codeforces.com/problemset/problem/34/B)
|
||||||
|
- [25A IQ test](https://codeforces.com/problemset/problem/25/A)
|
||||||
- [4A Watermelon](https://codeforces.com/problemset/problem/4/A)
|
- [4A Watermelon](https://codeforces.com/problemset/problem/4/A)
|
||||||
- [1A Theatre Square](https://codeforces.com/problemset/problem/1/A)
|
- [1A Theatre Square](https://codeforces.com/problemset/problem/1/A)
|
||||||
|
|
27
solutions/rust/src/bin/25A.rs
Normal file
27
solutions/rust/src/bin/25A.rs
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
use std::io;
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
let mut s = String::new();
|
||||||
|
io::stdin().read_line(&mut s).unwrap();
|
||||||
|
|
||||||
|
let mut s = String::new();
|
||||||
|
io::stdin().read_line(&mut s).unwrap();
|
||||||
|
let a: Vec<u64> = s.split_whitespace().map(|d| d.parse::<u64>().unwrap()).collect();
|
||||||
|
|
||||||
|
let mut evenness = vec![];
|
||||||
|
for i in a {
|
||||||
|
if i % 2 == 0 {
|
||||||
|
evenness.push(0);
|
||||||
|
} else {
|
||||||
|
evenness.push(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
let odds = evenness.iter().filter(|&n| *n == 1).count();
|
||||||
|
|
||||||
|
if odds == 1 {
|
||||||
|
println!("{}", evenness.iter().position(|&n| n == 1).unwrap()+1);
|
||||||
|
} else {
|
||||||
|
println!("{}", evenness.iter().position(|&n| n == 0).unwrap()+1);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue