結果

問題 No.1665 quotient replace
ユーザー phsplsphspls
提出日時 2022-10-02 17:44:21
言語 Rust
(1.77.0)
結果
AC  
実行時間 61 ms / 3,000 ms
コード長 1,020 bytes
コンパイル時間 1,633 ms
コンパイル使用メモリ 147,368 KB
実行使用メモリ 32,608 KB
最終ジャッジ日時 2023-08-26 15:39:14
合計ジャッジ時間 7,583 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 17 ms
17,432 KB
testcase_01 AC 15 ms
17,612 KB
testcase_02 AC 16 ms
17,420 KB
testcase_03 AC 16 ms
17,416 KB
testcase_04 AC 17 ms
17,432 KB
testcase_05 AC 17 ms
17,572 KB
testcase_06 AC 15 ms
17,552 KB
testcase_07 AC 15 ms
17,608 KB
testcase_08 AC 15 ms
17,620 KB
testcase_09 AC 17 ms
18,008 KB
testcase_10 AC 29 ms
22,332 KB
testcase_11 AC 50 ms
30,412 KB
testcase_12 AC 20 ms
18,916 KB
testcase_13 AC 58 ms
32,544 KB
testcase_14 AC 59 ms
32,104 KB
testcase_15 AC 60 ms
32,608 KB
testcase_16 AC 61 ms
32,092 KB
testcase_17 AC 59 ms
32,076 KB
testcase_18 AC 17 ms
17,616 KB
testcase_19 AC 17 ms
17,440 KB
testcase_20 AC 16 ms
17,624 KB
testcase_21 AC 16 ms
17,624 KB
testcase_22 AC 16 ms
17,576 KB
testcase_23 AC 16 ms
17,424 KB
testcase_24 AC 16 ms
17,540 KB
testcase_25 AC 17 ms
17,468 KB
testcase_26 AC 17 ms
17,576 KB
testcase_27 AC 16 ms
17,532 KB
testcase_28 AC 18 ms
18,048 KB
testcase_29 AC 20 ms
18,564 KB
testcase_30 AC 40 ms
24,920 KB
testcase_31 AC 51 ms
30,532 KB
testcase_32 AC 49 ms
29,640 KB
testcase_33 AC 29 ms
21,512 KB
testcase_34 AC 42 ms
26,152 KB
testcase_35 AC 39 ms
25,204 KB
testcase_36 AC 42 ms
25,700 KB
testcase_37 AC 39 ms
24,940 KB
testcase_38 AC 43 ms
26,544 KB
testcase_39 AC 35 ms
23,776 KB
testcase_40 AC 36 ms
23,776 KB
testcase_41 AC 35 ms
23,824 KB
testcase_42 AC 16 ms
17,608 KB
testcase_43 AC 16 ms
17,424 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

fn get_factors(n: usize) -> Vec<usize> {
    let mut ret = (0..=n).collect::<Vec<_>>();

    for i in 2..=(n as f64).sqrt().ceil() as usize {
        if ret[i] != i { continue; }
        for j in i..=n/i {
            ret[i*j] = i;
        }
    }

    ret
}

fn main() {
    let mut n = String::new();
    std::io::stdin().read_line(&mut n).ok();
    let n: usize = n.trim().parse().unwrap();
    let mut a = String::new();
    std::io::stdin().read_line(&mut a).ok();
    let a: Vec<usize> = a.trim().split_whitespace().map(|s| s.parse().unwrap()).collect();

    let factors = get_factors(1000000);
    let mut factor_cnt = vec![0usize; 1000001];
    for i in 2..=1000000{
        if i == factors[i] {
            factor_cnt[i] = 1;
        } else {
            factor_cnt[i] = factor_cnt[i/factors[i]] + 1;
        }
    }
    let result = (0..n).map(|i| factor_cnt[a[i]]).filter(|&v| v > 0).fold(0usize, |x, y| x ^ y);
    if result == 0 {
        println!("black");
    } else {
        println!("white");
    }
}
0