結果

問題 No.2 素因数ゲーム
ユーザー phspls
提出日時 2022-08-28 03:42:43
言語 Rust
(1.83.0 + proconio)
結果
AC  
実行時間 1 ms / 5,000 ms
コード長 606 bytes
コンパイル時間 13,401 ms
コンパイル使用メモリ 379,508 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-10-15 04:23:07
合計ジャッジ時間 14,715 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 31
権限があれば一括ダウンロードができます

ソースコード

diff #

use std::collections::HashMap;


fn main() {
    let mut n = String::new();
    std::io::stdin().read_line(&mut n).ok();
    let n: usize = n.trim().parse().unwrap();
    
    let mut nval = n;
    let mut primes = HashMap::new();
    for i in 2..=(n as f64).sqrt().floor() as usize {
        while nval % i == 0 {
            *primes.entry(i).or_insert(0usize) += 1;
            nval /= i;
        }
    }
    if nval > 1 { primes.insert(nval, 1); }
    let result = primes.values().fold(0usize, |x, &y| x ^ y);
    if result == 0 {
        println!("Bob");
    } else {
        println!("Alice");
    }
}
0