Submission #2973078

Source Code Expand

Copy
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>().split_whitespace()
        .map(|e| e.parse().ok().unwrap()).collect()
}

fn trailing_zeros(x: i32) -> i32 {
    let mut c = 0;
    let mut x = x;
    while x > 0 {
        if x % 2 != 0 { break; }
        x /= 2;
        c += 1;
    }
    c 
}
fn solve(a: Vec<i32>) {
    let ans:i32 = a.iter().map(|x| trailing_zeros(*x)).min().unwrap();
    println!("{}", ans);
}
fn main() {
    let _ = read::<i32>();
    let a = read_vec::<i32>();
    solve(a);
}

Submission Info

Submission Time
Task ABC081B - Shift only
User naoya_t
Language Rust (1.15.1)
Score 200
Code Size 703 Byte
Status
Exec Time 2 ms
Memory 4352 KB

Test Cases

Set Name Score / Max Score Test Cases
Sample 0 / 0 sample1.txt, sample2.txt, sample3.txt
All 200 / 200 sample1.txt, sample2.txt, sample3.txt, 1.txt, 2.txt, 3.txt, 4.txt, 5.txt, 6.txt, 7.txt, sample1.txt, sample2.txt, sample3.txt
Case Name Status Exec Time Memory
1.txt 2 ms 4352 KB
2.txt 2 ms 4352 KB
3.txt 2 ms 4352 KB
4.txt 2 ms 4352 KB
5.txt 2 ms 4352 KB
6.txt 2 ms 4352 KB
7.txt 2 ms 4352 KB
sample1.txt 2 ms 4352 KB
sample2.txt 2 ms 4352 KB
sample3.txt 2 ms 4352 KB