結果

問題 No.1665 quotient replace
ユーザー koba-e964koba-e964
提出日時 2021-09-04 10:33:02
言語 Rust
(1.77.0)
結果
AC  
実行時間 118 ms / 3,000 ms
コード長 1,464 bytes
コンパイル時間 13,498 ms
コンパイル使用メモリ 381,012 KB
実行使用メモリ 17,588 KB
最終ジャッジ日時 2024-05-09 23:13:55
合計ジャッジ時間 19,470 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 48 ms
9,728 KB
testcase_01 AC 48 ms
9,728 KB
testcase_02 AC 48 ms
9,616 KB
testcase_03 AC 47 ms
9,536 KB
testcase_04 AC 47 ms
9,784 KB
testcase_05 AC 47 ms
9,652 KB
testcase_06 AC 49 ms
9,856 KB
testcase_07 AC 48 ms
9,728 KB
testcase_08 AC 49 ms
9,728 KB
testcase_09 AC 50 ms
9,856 KB
testcase_10 AC 71 ms
12,308 KB
testcase_11 AC 100 ms
15,664 KB
testcase_12 AC 53 ms
10,368 KB
testcase_13 AC 116 ms
17,496 KB
testcase_14 AC 118 ms
17,488 KB
testcase_15 AC 114 ms
17,536 KB
testcase_16 AC 116 ms
17,588 KB
testcase_17 AC 115 ms
17,536 KB
testcase_18 AC 48 ms
9,664 KB
testcase_19 AC 50 ms
9,644 KB
testcase_20 AC 49 ms
9,828 KB
testcase_21 AC 48 ms
9,728 KB
testcase_22 AC 48 ms
9,728 KB
testcase_23 AC 47 ms
9,636 KB
testcase_24 AC 48 ms
9,656 KB
testcase_25 AC 48 ms
9,604 KB
testcase_26 AC 48 ms
9,728 KB
testcase_27 AC 48 ms
9,600 KB
testcase_28 AC 50 ms
9,808 KB
testcase_29 AC 52 ms
10,240 KB
testcase_30 AC 81 ms
13,792 KB
testcase_31 AC 100 ms
15,744 KB
testcase_32 AC 96 ms
15,304 KB
testcase_33 AC 66 ms
11,828 KB
testcase_34 AC 87 ms
14,184 KB
testcase_35 AC 83 ms
13,824 KB
testcase_36 AC 84 ms
14,080 KB
testcase_37 AC 82 ms
13,728 KB
testcase_38 AC 89 ms
14,464 KB
testcase_39 AC 77 ms
12,928 KB
testcase_40 AC 76 ms
13,060 KB
testcase_41 AC 77 ms
12,988 KB
testcase_42 AC 47 ms
9,652 KB
testcase_43 AC 46 ms
9,760 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes.by_ref().map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr,) => {};
    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };
    ($next:expr, $t:ty) => ($next().parse::<$t>().expect("Parse error"));
}

fn main() {
    input! {
        n: usize,
        a: [usize; n],
    }
    const W: usize = 1_000_001;
    let mut seen = vec![0; W];
    let mut g = vec![0; W];
    for i in 1..W {
        let mut mex = 0;
        while (seen[i] & 1 << mex) != 0 {
            mex += 1;
        }
        g[i] = mex;
        for j in 2..(W - 1) / i + 1 {
            seen[i * j] |= 1 << g[i];
        }
    }
    let mut ans = 0;
    for a in a {
        ans ^= g[a];
    }
    println!("{}", if ans == 0 { "black" } else { "white" });
}
0