結果

問題 No.2 素因数ゲーム
ユーザー sewoiwatakisewoiwataki
提出日時 2018-02-21 00:27:38
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 1,084 bytes
コンパイル時間 542 ms
コンパイル使用メモリ 59,344 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-27 04:49:27
合計ジャッジ時間 1,584 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 1 ms
4,376 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 AC 1 ms
4,376 KB
testcase_13 AC 1 ms
4,376 KB
testcase_14 AC 2 ms
4,380 KB
testcase_15 AC 1 ms
4,380 KB
testcase_16 AC 2 ms
4,376 KB
testcase_17 AC 2 ms
4,376 KB
testcase_18 AC 2 ms
4,380 KB
testcase_19 AC 1 ms
4,376 KB
testcase_20 AC 2 ms
4,376 KB
testcase_21 AC 2 ms
4,380 KB
testcase_22 AC 2 ms
4,376 KB
testcase_23 AC 2 ms
4,376 KB
testcase_24 AC 1 ms
4,380 KB
testcase_25 AC 1 ms
4,376 KB
testcase_26 AC 1 ms
4,376 KB
testcase_27 AC 1 ms
4,376 KB
testcase_28 AC 2 ms
4,376 KB
testcase_29 AC 1 ms
4,384 KB
testcase_30 AC 1 ms
4,380 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:52:9: warning: ‘c[0]’ may be used uninitialized in this function [-Wmaybe-uninitialized]
     judg=c[0];
     ~~~~^~~~~

ソースコード

diff #

#include<iostream>
#include<cmath>

//#define DEBUG
#define NMAX 100000000
#define PRI_MAX 10000 /*root(MAX)*/

using namespace std;

int main(){
    int hur[PRI_MAX+1];
    int N;
    int sN;
    int c[30];
    int var;
    int judg;

    cin>>N;
    sN=(int)sqrt((double)N)+1;

    for(int i=0;i<=sN;i++) hur[i]=false;
    hur[0]=true;
    hur[1]=true;
    var=0;
    for(int i=0;i<=sN;i++){
        if(hur[i]!=true){
            for(int j=i;j<=sN;j+=i){
                hur[j]=true;
            }
            if(N%i==0&&N!=1){
                c[var]=0;
                while(N%i==0){
                    N/=i;
                    c[var]++;
                }
                var++;
            }
        }
    }
    if(N!=1){
        c[var]=1;
        var++;
    }
    #ifdef DEBUG
    for(int i=0;i<var;i++){
        cout<<c[i]<<endl;
    }
    #endif

    //ニム和 https://ja.wikipedia.org/wiki/%E3%83%8B%E3%83%A0
    //lookhint(wikipedia)
    judg=c[0];
    for(int i=1;i<var;i++){
        judg^=c[i];
    }

    if(judg!=0) cout<<"Alice"<<endl;
    else cout<<"Bob"<<endl;
}
0