結果

問題 No.103 素因数ゲーム リターンズ
ユーザー Kenshin2438Kenshin2438
提出日時 2022-09-27 21:50:29
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 7 ms / 5,000 ms
コード長 1,053 bytes
コンパイル時間 1,459 ms
コンパイル使用メモリ 169,216 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-24 04:06:16
合計ジャッジ時間 3,241 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

using ll = long long;
#define all(a) begin(a), end(a)
#define sz(x) (int)((x).size())

#ifdef LOCAL
#include "debug.hpp"
#else
#define debug(...) 42
#endif

void solve() {
  const int N = 1e4 + 1;
  array<vector<int>, N> pfac;
  for (int i = 2; i < N; i++) {
    int n = i;
    for (int d = 2; d * d <= n; d++) {
      if (n % d == 0) pfac[i].emplace_back(d);
      while (n % d == 0) n /= d;
    }
    if (n != 1) pfac[i].emplace_back(n);
  }

  array<int, N> grundy;
  for (int i = 2; i < N; i++) {
    int mex[100] = {};
    for (const int &d : pfac[i]) {
      mex[grundy[i / d]] += 1;
      if (i % (d * d) == 0) {
        mex[grundy[i / (d * d)]] += 1;
      }
      while (mex[grundy[i]]) grundy[i] += 1;
    }
  }

  int n; cin >> n;
  int nim = 0;
  for (int i = 0; i < n; i++) {
    int x; cin >> x;
    nim ^= grundy[x];
  }
  cout << (nim ? "Alice" : "Bob") << '\n';
}

int main() {
  cin.tie(nullptr)->sync_with_stdio(false);

  int T = 1;
  // cin >> T;
  while (T--) solve();

  return 0;
}
0