結果
問題 |
No.2 素因数ゲーム
|
ユーザー |
|
提出日時 | 2025-08-02 12:40:46 |
言語 | Rust (1.83.0 + proconio) |
結果 |
AC
|
実行時間 | 2 ms / 5,000 ms |
コード長 | 1,236 bytes |
コンパイル時間 | 14,076 ms |
コンパイル使用メモリ | 392,748 KB |
実行使用メモリ | 7,716 KB |
最終ジャッジ日時 | 2025-08-02 12:41:02 |
合計ジャッジ時間 | 14,836 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 31 |
ソースコード
// #[rustfmt::skip] // pub mod lib {pub use ac_library::*;pub use itertools::{join, Combinations, Itertools, MultiProduct, Permutations};pub use proconio::{input,marker::{Chars, Usize1}};pub use std::{cmp::*, collections::*, mem::swap};pub use regex::Regex;pub use superslice::Ext;pub use num_traits::{One, ToPrimitive, FromPrimitive, PrimInt};#[macro_export]macro_rules! degg {($($val:expr),+ $(,)?) => {println!("[{}:{}] {}",file!(),line!(),{let mut parts = Vec::new();$(parts.push(format!("{} = {:?}", stringify!($val), &$val));)+parts.join(", ")})}}} // use lib::*; use proconio::input; fn factorization(mut x: usize) -> Vec<(usize, usize)> { let mut resu = Vec::new(); for i in 2.. { if i*i > x { break; } if x % i != 0 { continue; } let mut e = 0; while x % i == 0 { e += 1; x /= i; } resu.push((i, e)); } if x != 1 { resu.push((x, 1)); } resu } fn main() { input! { n: usize, } let fact = factorization(n).iter().map(|&e| e.1).collect::<Vec<_>>(); let ans = fact.iter().fold(0, |acc, &now| acc ^ now); if ans != 0 { println!("Alice"); } else { println!("Bob"); } }