結果
問題 | No.153 石の山 |
ユーザー |
|
提出日時 | 2015-02-16 01:10:15 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 2 ms / 5,000 ms |
コード長 | 700 bytes |
コンパイル時間 | 423 ms |
コンパイル使用メモリ | 54,876 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-10-14 14:29:44 |
合計ジャッジ時間 | 1,266 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 27 |
コンパイルメッセージ
main.cpp: In function ‘int rec(int, int*)’: main.cpp:29:1: warning: control reaches end of non-void function [-Wreturn-type] 29 | } | ^
ソースコード
#include<iostream> #include<cstring> using namespace std; const int BUF = 105; int N; void read() { cin >> N; } int rec(int n, int dp[BUF]) { if (n == 0) return 1; if (n == 1) return 0; int &ret = dp[n]; if (ret != -1) return ret; bool S[BUF] = {}; S[rec(n / 2, dp) ^ rec((n + 1) / 2, dp)] = true; if (n >= 3) S[rec(n / 3, dp) ^ rec((n + 1) / 3, dp) ^ rec((n + 2) / 3, dp)] = true; for (int i = 0; i < BUF; ++i) if (!S[i]) return ret = i; } void work() { int dp[BUF]; memset(dp, - 1, sizeof(dp)); cout << (rec(N, dp) == 0 ? 'B' : 'A') << endl; } int main() { read(); work(); return 0; }