結果

問題 No.103 素因数ゲーム リターンズ
ユーザー SSRSSSRS
提出日時 2020-11-15 20:24:44
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 5 ms / 5,000 ms
コード長 839 bytes
コンパイル時間 1,716 ms
コンパイル使用メモリ 173,120 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-30 07:06:13
合計ジャッジ時間 2,656 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 4 ms
4,380 KB
testcase_01 AC 5 ms
4,380 KB
testcase_02 AC 5 ms
4,376 KB
testcase_03 AC 4 ms
4,376 KB
testcase_04 AC 5 ms
4,380 KB
testcase_05 AC 4 ms
4,380 KB
testcase_06 AC 5 ms
4,380 KB
testcase_07 AC 4 ms
4,380 KB
testcase_08 AC 4 ms
4,380 KB
testcase_09 AC 4 ms
4,376 KB
testcase_10 AC 5 ms
4,380 KB
testcase_11 AC 5 ms
4,376 KB
testcase_12 AC 5 ms
4,376 KB
testcase_13 AC 4 ms
4,376 KB
testcase_14 AC 5 ms
4,376 KB
testcase_15 AC 4 ms
4,380 KB
testcase_16 AC 4 ms
4,376 KB
testcase_17 AC 4 ms
4,380 KB
testcase_18 AC 4 ms
4,376 KB
testcase_19 AC 4 ms
4,380 KB
testcase_20 AC 5 ms
4,380 KB
testcase_21 AC 4 ms
4,376 KB
testcase_22 AC 5 ms
4,380 KB
testcase_23 AC 5 ms
4,376 KB
testcase_24 AC 5 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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;
  }
}
0