結果

問題 No.103 素因数ゲーム リターンズ
ユーザー nemutainemutai
提出日時 2023-04-29 01:35:35
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 424 ms / 5,000 ms
コード長 1,011 bytes
コンパイル時間 1,669 ms
コンパイル使用メモリ 171,100 KB
実行使用メモリ 81,536 KB
最終ジャッジ日時 2024-04-29 01:53:21
合計ジャッジ時間 13,200 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 424 ms
81,280 KB
testcase_01 AC 417 ms
81,280 KB
testcase_02 AC 421 ms
81,280 KB
testcase_03 AC 407 ms
81,408 KB
testcase_04 AC 413 ms
81,280 KB
testcase_05 AC 411 ms
81,280 KB
testcase_06 AC 408 ms
81,280 KB
testcase_07 AC 412 ms
81,280 KB
testcase_08 AC 402 ms
81,280 KB
testcase_09 AC 406 ms
81,408 KB
testcase_10 AC 401 ms
81,280 KB
testcase_11 AC 405 ms
81,536 KB
testcase_12 AC 403 ms
81,536 KB
testcase_13 AC 404 ms
81,280 KB
testcase_14 AC 412 ms
81,408 KB
testcase_15 AC 408 ms
81,408 KB
testcase_16 AC 400 ms
81,408 KB
testcase_17 AC 406 ms
81,408 KB
testcase_18 AC 403 ms
81,408 KB
testcase_19 AC 408 ms
81,408 KB
testcase_20 AC 405 ms
81,408 KB
testcase_21 AC 408 ms
81,280 KB
testcase_22 AC 405 ms
81,408 KB
testcase_23 AC 409 ms
81,408 KB
testcase_24 AC 409 ms
81,536 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

#define all(v) v.begin(),v.end()
using ll = long long;
using ull = unsigned long long;
using vll=vector<ll>;
using vvll = vector<vector<ll>>;
const ll INF=1ll<<60;
using vp=vector<pair<ll, ll>>;

int main(){
    ll N;
    cin>>N;
    vll A(N);
    for(auto &e:A) cin >>e;
    
   vector<ll> pri(1e7);
   for(int i=0;i<=1e7;i++) pri[i]=i;
   for(ll i=2;i<=1e7;i++){
       if(pri[i]!=i) continue;
       ll j=1;
       while(i*j<=1e7){
           pri[i*j]=min(i,pri[i*j]);
           j++;
       }
   }

    vll B;
    for(int i=0;i<N;i++){
        ll now=pri[A[i]];
        ll cnt=0;
        while(A[i]>1){
            if(now==pri[A[i]])A[i]/=pri[A[i]],cnt++;
            else{
                B.push_back(cnt%3);
                now=pri[A[i]];
                A[i]/=pri[A[i]];
                cnt=1;
            }
        }
        B.push_back(cnt%3);
    }


    ll a=0;
    for(auto x:B) a^=x;
    if(a) cout << "Alice" << endl;
    else cout << "Bob" << endl;
}
0