結果

問題 No.2 素因数ゲーム
ユーザー bonntanname0316bonntanname0316
提出日時 2020-04-15 15:41:09
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
RE  
実行時間 -
コード長 1,549 bytes
コンパイル時間 1,778 ms
コンパイル使用メモリ 173,788 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-04-09 18:42:06
合計ジャッジ時間 3,110 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,812 KB
testcase_01 RE -
testcase_02 AC 2 ms
6,944 KB
testcase_03 AC 2 ms
6,940 KB
testcase_04 AC 2 ms
6,944 KB
testcase_05 AC 1 ms
6,940 KB
testcase_06 AC 2 ms
6,940 KB
testcase_07 AC 2 ms
6,944 KB
testcase_08 AC 2 ms
6,940 KB
testcase_09 AC 2 ms
6,940 KB
testcase_10 AC 2 ms
6,944 KB
testcase_11 AC 2 ms
6,944 KB
testcase_12 AC 2 ms
6,940 KB
testcase_13 AC 2 ms
6,940 KB
testcase_14 AC 2 ms
6,944 KB
testcase_15 AC 2 ms
6,944 KB
testcase_16 AC 2 ms
6,944 KB
testcase_17 AC 2 ms
6,944 KB
testcase_18 AC 2 ms
6,944 KB
testcase_19 RE -
testcase_20 AC 2 ms
6,940 KB
testcase_21 RE -
testcase_22 AC 2 ms
6,944 KB
testcase_23 AC 2 ms
6,944 KB
testcase_24 AC 2 ms
6,948 KB
testcase_25 AC 2 ms
6,944 KB
testcase_26 AC 2 ms
6,940 KB
testcase_27 AC 2 ms
6,940 KB
testcase_28 AC 2 ms
6,940 KB
testcase_29 AC 2 ms
6,940 KB
testcase_30 AC 2 ms
6,944 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> P;
typedef priority_queue<P,vector<P>,greater<P>> P_queue;

#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define mp make_pair
#define ALL(a) a.begin(),a.end()
#define SORT(a) sort(ALL(a))
#define U_ERASE(V) V.erase(unique(ALL(V)), V.end());

const ll MOD=998244353;
const ll mod=1000000007;
const ll INF=1e15;
vec dx={1,0,-1,0};
vec dy={0,1,0,-1};

vec Eratosthenes(ll N){
    vec ret;
    vector<bool> a(N+1,true);
    a.at(0)=false;
    a.at(1)=false;
    REP(i,2,N+1){
        if(a.at(i)) for(ll k=2*i;k<=N;k+=i) a.at(k)=false;
    }
    rep(i,N+1) if(a.at(i)) ret.pb(i);
    return ret;
}

vector<P> Soin(ll N){
    ll BIG=N+3, SMALL=3;
    while(BIG>SMALL+1){
        ll MID=(BIG+SMALL)/2;
        if(MID*MID>N) BIG=MID;
        else SMALL=MID;
    }
    vec Sosu=Eratosthenes(BIG);
    vector<P> ret;
    for(int i=0;Sosu.at(i)*Sosu.at(i)<=N;i++){
        ll k=Sosu.at(i);
        ll count=0;
        while(true){
            if(N%k!=0) break;
            count++;
            N/=k;
        }
        if(count!=0) ret.pb(mp(k,count));
    }
    if(N!=1) ret.pb(mp(N,1));
    return ret;
}

ll Nim(ll x){
    vector<P> y=Soin(x);
    ll ret=0;
    rep(i,y.size()) {
        ll kari=y.at(i).second;
        ret=(ret^kari);
    }
    return ret;

}

int main(){
    ll N; cin>>N;
    if(Nim(N)) cout<<"Alice"<<endl;
    else cout<<"Bob"<<endl;
}
0