結果
| 問題 |
No.153 石の山
|
| コンテスト | |
| ユーザー |
mayoko_
|
| 提出日時 | 2015-02-16 00:44:31 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 5,000 ms |
| コード長 | 793 bytes |
| コンパイル時間 | 598 ms |
| コンパイル使用メモリ | 78,948 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-10-14 14:29:41 |
| 合計ジャッジ時間 | 1,379 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 27 |
ソースコード
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
using namespace std;
typedef long long ll;
int grundy(int x) {
set<int> s;
if (x >= 3) {
int a = x/3;
int b = (x-a) / 2;
int c = x-a-b;
s.insert(grundy(a)^grundy(b)^grundy(c));
}
if (x >= 2) {
int a = x/2;
int b = x-a;
s.insert(grundy(a)^grundy(b));
}
int g = 0;
while (s.count(g)) g++;
return g;
}
int main(void) {
int N;
cin >> N;
int ans = grundy(N);
if (ans == 0) cout << "B" << endl;
else cout << "A" << endl;
return 0;
}
mayoko_