結果

問題 No.103 素因数ゲーム リターンズ
ユーザー beetbeet
提出日時 2018-12-20 19:51:43
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 5 ms / 5,000 ms
コード長 946 bytes
コンパイル時間 3,263 ms
コンパイル使用メモリ 210,060 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-26 01:11:39
合計ジャッジ時間 3,203 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}


Int isprime(Int x){
  if(x<=1) return 0;
  for(Int i=2;i*i<=x;i++)
    if(x%i==0) return 0;
  return 1;
}

//INSERT ABOVE HERE
const Int MAX = 1e4+100;
Int dp[MAX];
vector<Int> ps;
Int dfs(Int x){
  Int &res=dp[x];
  if(~res) return res;
  res=0;
  set<Int> ss;
  for(Int p:ps){
    if(p>x) break;
    if(x%p==0) ss.emplace(dfs(x/p));
    if(x%(p*p)==0) ss.emplace(dfs(x/(p*p)));    
  }
  while(ss.count(res)) res++;
  return res;
}

signed main(){
  Int n;
  cin>>n;
  vector<Int> x(n);
  for(Int i=0;i<n;i++) cin>>x[i];

  for(Int i=0;i<MAX;i++)
    if(isprime(i)) ps.emplace_back(i);
  
  memset(dp,-1,sizeof(dp));
  Int ans=0;
  for(Int i=0;i<n;i++) ans^=dfs(x[i]);
  cout<<(ans?"Alice":"Bob")<<endl;
  return 0;
}
0