結果
問題 |
No.103 素因数ゲーム リターンズ
|
ユーザー |
|
提出日時 | 2025-08-02 15:12:38 |
言語 | Rust (1.83.0 + proconio) |
結果 |
AC
|
実行時間 | 2 ms / 5,000 ms |
コード長 | 1,368 bytes |
コンパイル時間 | 12,179 ms |
コンパイル使用メモリ | 398,188 KB |
実行使用メモリ | 7,720 KB |
最終ジャッジ日時 | 2025-08-02 15:12:56 |
合計ジャッジ時間 | 13,615 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 5 |
other | AC * 20 |
ソースコード
// #[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, m: [usize; n] } let mut ans = 0; for &num in m.iter() { let fact = factorization(num); let c = fact.iter().map(|&e| e.1).collect::<Vec<_>>(); let tmp = c.iter().fold(0, |acc, &now| acc ^ (now % 3)); ans ^= tmp; } if ans != 0 { println!("Alice"); } else { println!("Bob"); } }