結果
| 問題 | No.153 石の山 |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-08-30 15:52:09 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 763 bytes |
| コンパイル時間 | 1,799 ms |
| コンパイル使用メモリ | 169,036 KB |
| 実行使用メモリ | 6,948 KB |
| 最終ジャッジ日時 | 2024-08-30 15:52:12 |
| 合計ジャッジ時間 | 3,121 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 22 WA * 5 |
ソースコード
#include<bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
int n;
cin >> n;
vector<int> memo(n+1, -1);
auto g = [&] (auto self, int a) -> int {
if (a == 0) return memo[a] = 0;
if (a == 1) return memo[a] = 0;
if (memo[a] != -1) return memo[a];
int res = 0;
if (a & 1) {
res ^= self(self, a/2);
res ^= self(self, a/2 + 1);
} else {
res ^= self(self, a/2);
}
if (a % 3 == 0) {
res ^= self(self, a/3);
} else {
res ^= self(self, a/3);
res ^= self(self, a/3 + 1);
}
return -1;
};
cout << (g(g, n) == 0? "B" : "A") << "\n";
}