結果
問題 | No.103 素因数ゲーム リターンズ |
ユーザー |
![]() |
提出日時 | 2020-11-15 20:24:44 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 6 ms / 5,000 ms |
コード長 | 839 bytes |
コンパイル時間 | 1,758 ms |
コンパイル使用メモリ | 175,816 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-07-23 01:21:30 |
合計ジャッジ時間 | 2,867 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 5 |
other | AC * 20 |
ソースコード
#include <bits/stdc++.h> using namespace std; int main(){ int N; cin >> N; vector<int> M(N); for (int i = 0; i < N; i++){ cin >> M[i]; } vector<int> grundy(10001, 0); for (int i = 2; i <= 10000; i++){ int num = i; vector<int> p; for (int j = 2; j * j <= num; j++){ if (num % j == 0){ p.push_back(j); while (num % j == 0){ num /= j; } } } if (num > 1){ p.push_back(num); } set<int> st; for (int j : p){ st.insert(grundy[i / j]); if (i % (j * j) == 0){ st.insert(grundy[i / (j * j)]); } } while (st.count(grundy[i])){ grundy[i]++; } } int X = 0; for (int i = 0; i < N; i++){ X ^= grundy[M[i]]; } if (X == 0){ cout << "Bob" << endl; } else { cout << "Alice" << endl; } }