結果

問題 No.103 素因数ゲーム リターンズ
ユーザー nemutainemutai
提出日時 2023-04-29 01:35:35
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 312 ms / 5,000 ms
コード長 1,011 bytes
コンパイル時間 1,730 ms
コンパイル使用メモリ 170,340 KB
実行使用メモリ 81,316 KB
最終ジャッジ日時 2023-08-11 09:20:53
合計ジャッジ時間 10,785 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 310 ms
81,028 KB
testcase_01 AC 309 ms
80,976 KB
testcase_02 AC 304 ms
80,976 KB
testcase_03 AC 311 ms
81,064 KB
testcase_04 AC 310 ms
80,980 KB
testcase_05 AC 312 ms
81,040 KB
testcase_06 AC 309 ms
81,024 KB
testcase_07 AC 307 ms
81,024 KB
testcase_08 AC 311 ms
81,132 KB
testcase_09 AC 307 ms
81,080 KB
testcase_10 AC 310 ms
81,032 KB
testcase_11 AC 304 ms
81,180 KB
testcase_12 AC 305 ms
80,980 KB
testcase_13 AC 304 ms
80,976 KB
testcase_14 AC 310 ms
81,080 KB
testcase_15 AC 305 ms
80,976 KB
testcase_16 AC 305 ms
81,088 KB
testcase_17 AC 305 ms
81,028 KB
testcase_18 AC 309 ms
80,980 KB
testcase_19 AC 310 ms
80,976 KB
testcase_20 AC 312 ms
80,980 KB
testcase_21 AC 307 ms
81,036 KB
testcase_22 AC 312 ms
81,068 KB
testcase_23 AC 308 ms
81,316 KB
testcase_24 AC 309 ms
81,136 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