結果

問題 No.2 素因数ゲーム
ユーザー cra77756176
提出日時 2022-12-05 22:17:10
言語 Rust
(1.83.0 + proconio)
結果
AC  
実行時間 317 ms / 5,000 ms
コード長 639 bytes
コンパイル時間 15,673 ms
コンパイル使用メモリ 383,368 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2024-10-12 18:50:09
合計ジャッジ時間 15,750 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 31
権限があれば一括ダウンロードができます

ソースコード

diff #

fn get_num_of_each_factor(mut n: u64) -> Vec<u64> {
    let mut result = vec![];

    for p in 2.. {
        let mut i = 0;
        while n % p == 0 {
            n /= p;
            i += 1;
        }
        if i > 0 {
            result.push(i);
            if n == 1 {
                break;
            }
        }
    }

    result
}

fn main() {
    let mut n = String::new();
    std::io::stdin().read_line(&mut n).ok();
    let n: u64 = n.trim().parse().unwrap();

    let win = get_num_of_each_factor(n).iter().fold(0, |acc, x| acc ^ x);

    if win == 0 {
        println!("Bob");
    } else {
        println!("Alice");
    }
}
0