結果
問題 | No.153 石の山 |
ユーザー |
![]() |
提出日時 | 2015-07-29 22:17:34 |
言語 | C++11 (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 1 ms / 5,000 ms |
コード長 | 824 bytes |
コンパイル時間 | 173 ms |
コンパイル使用メモリ | 23,424 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-10-14 14:34:59 |
合計ジャッジ時間 | 1,002 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 27 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:8:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 8 | scanf("%d", &N); | ~~~~~^~~~~~~~~~
ソースコード
#include <cstdio>#include <cstring>int N;int grundy[101], count[101];int main(){scanf("%d", &N);for(int i=1;i<=N;i++){memset(count, 0, sizeof(count));if(i >= 2){if(i % 2 == 0){++count[0];}else{++count[grundy[i/2]^grundy[(i+1)/2]];}}if(i >= 3){if(i % 3 == 0){++count[grundy[i/3]];}else if(i % 3 == 1){++count[grundy[(i+2)/3]];}else{++count[grundy[i/3]];}}for(int j=0;j<=N;j++){if(!count[j]){grundy[i] = j;break;}}}if(grundy[N] == 0){puts("B");}else{puts("A");}}