結果

問題 No.2 素因数ゲーム
ユーザー Bantako
提出日時 2017-07-25 18:06:44
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 3 ms / 5,000 ms
コード長 552 bytes
コンパイル時間 3,290 ms
コンパイル使用メモリ 157,184 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-12-26 13:10:10
合計ジャッジ時間 3,840 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 31
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:4:1: warning: ISO C++ forbids declaration of ‘main’ with no type [-Wreturn-type]
    4 | main(){
      | ^~~~
main.cpp: In function ‘int main()’:
main.cpp:12:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   12 |     scanf("%d",&N);
      |     ~~~~~^~~~~~~~~

ソースコード

diff #

#include<bits/stdc++.h>
int prime[10000];
int count[10001];
main(){
    prime[0] = 1;
    prime[1] = 1;
    for(int i = 2;i*i<=10000;i++){
        if(prime[i]) continue;
        for(int j = i*2;j < 10000;j+=i) prime[j] = 1;
    }
    int N;
    scanf("%d",&N);
    for(int i = 2;i < 10000;i++){
        if(prime[i]) continue;
        if(N%i==0){
            count[i]++;
            N/=i;
            i--;
        }
    }
    count[10000] = N!=1;
    int nim = 0;
    for(int i = 0;i < 10001;i++) nim ^= count[i];
    printf("%s\n",nim?"Alice":"Bob");
}
0