結果
問題 | No.153 石の山 |
ユーザー |
![]() |
提出日時 | 2020-05-27 20:37:49 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 5,000 ms |
コード長 | 680 bytes |
コンパイル時間 | 1,440 ms |
コンパイル使用メモリ | 167,588 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-10-13 03:47:11 |
合計ジャッジ時間 | 2,417 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 27 |
コンパイルメッセージ
main.cpp: In function 'int f(int)': main.cpp:30:1: warning: control reaches end of non-void function [-Wreturn-type] 30 | } | ^
ソースコード
#include <bits/stdc++.h> using namespace std; int memo[110]; int f(int n) { if (memo[n] != -1) return memo[n]; if (n == 1) return 0; int used[5] = {}; if (n >= 2) { int tmp = f(n / 2) ^ f(n - n / 2); used[tmp] = 1; } if (n >= 3) { int a = n / 3; int b = (n - a) / 2; int c = n - a - b; int tmp = f(a) ^ f(b) ^ f(c); used[tmp] = 1; } for (int i = 0; i < 3; i++) { if (!used[i]) return memo[n] = i; } } int main() { int N; cin >> N; for (int i = 0; i <= N; i++) { memo[i] = -1; } cout << (f(N) ? 'A' : 'B') << endl; }