結果

問題 No.2 素因数ゲーム
ユーザー k
提出日時 2021-02-18 21:59:35
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 576 bytes
コンパイル時間 1,833 ms
コンパイル使用メモリ 198,256 KB
最終ジャッジ日時 2025-01-18 22:38:40
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 31
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

#define REP(i,n) for(int i=0; i<(int)(n); i++)

map<long long, int> factorize(long long n) {
  map<long long, int> ret;

  for (long long i = 2; i * i <= n; i++) {
    while (n % i == 0) {
      ++ret[i];
      n /= i;
    }
  }

  if (n != 1)
    ret[n] = 1;

  return ret;
}

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  int n;
  cin >> n;

  auto f = factorize(n);
  int sum = 0;
  for (auto &[_, v]: f)
    sum ^= v;

  if (sum)
    cout << "Alice" << endl;
  else
    cout << "Bob" << endl;

  return 0;
}
0