結果

問題 No.103 素因数ゲーム リターンズ
ユーザー parukiparuki
提出日時 2016-09-28 17:08:30
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 7 ms / 5,000 ms
コード長 1,263 bytes
コンパイル時間 1,843 ms
コンパイル使用メモリ 176,204 KB
実行使用メモリ 5,260 KB
最終ジャッジ日時 2023-08-13 13:01:44
合計ジャッジ時間 3,062 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 6 ms
5,024 KB
testcase_01 AC 6 ms
5,244 KB
testcase_02 AC 5 ms
4,976 KB
testcase_03 AC 6 ms
5,052 KB
testcase_04 AC 6 ms
5,000 KB
testcase_05 AC 6 ms
5,012 KB
testcase_06 AC 6 ms
5,064 KB
testcase_07 AC 6 ms
4,980 KB
testcase_08 AC 6 ms
5,040 KB
testcase_09 AC 6 ms
5,156 KB
testcase_10 AC 6 ms
5,004 KB
testcase_11 AC 6 ms
5,004 KB
testcase_12 AC 6 ms
5,028 KB
testcase_13 AC 6 ms
5,260 KB
testcase_14 AC 6 ms
5,108 KB
testcase_15 AC 6 ms
5,096 KB
testcase_16 AC 6 ms
5,068 KB
testcase_17 AC 6 ms
5,068 KB
testcase_18 AC 7 ms
5,012 KB
testcase_19 AC 6 ms
5,160 KB
testcase_20 AC 6 ms
5,060 KB
testcase_21 AC 6 ms
5,156 KB
testcase_22 AC 6 ms
4,996 KB
testcase_23 AC 6 ms
5,120 KB
testcase_24 AC 6 ms
4,984 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include "bits/stdc++.h"
using namespace std;
#define FOR(i,j,k) for(int (i)=(j);(i)<(int)(k);++(i))
#define rep(i,j) FOR(i,0,j)
#define each(x,y) for(auto &(x):(y))
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define debug(x) cout<<#x<<": "<<(x)<<endl
#define smax(x,y) (x)=max((x),(y))
#define smin(x,y) (x)=min((x),(y))
#define MEM(x,y) memset((x),(y),sizeof (x))
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;

map<int, int> factorize(int n){
    map<int, int> res;
    for(int i=2; (long long)i*i<=n; ++i){
        while(n%i==0){
            n /= i;
            ++res[i];
        }
    }
    if(n!=1) ++res[n];
    return res;
}

map<int, int> F[10001];

int dp[10001];
int f(int m){
    if(m == 1)return 0;
    int &r = dp[m];
    if(r != -1)return r;
    r = 0;
    set<int> S;
    each(p, F[m]){
        int n = m;
        rep(i,min(2,p.second)){
            n /= p.first;
            S.insert(f(n));
        }
    }
    while(S.count(r))r++;
    return r;
}

int main(){
    FOR(i, 1, 10001)F[i] = factorize(i);
    MEM(dp, -1);
    
    int x = 0, N, M;
    cin >> N;
    rep(i, N){
        cin >> M;
        x ^= f(M);
    }
    puts(x ? "Alice" : "Bob");
}
0