結果
| 問題 |
No.153 石の山
|
| コンテスト | |
| ユーザー |
izuru_matsuura
|
| 提出日時 | 2016-09-29 21:43:55 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,261 bytes |
| コンパイル時間 | 1,651 ms |
| コンパイル使用メモリ | 166,084 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-11-21 10:40:04 |
| 合計ジャッジ時間 | 2,468 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 22 WA * 5 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
namespace {
typedef double real;
typedef long long ll;
template<class T> ostream& operator<<(ostream& os, const vector<T>& vs) {
if (vs.empty()) return os << "[]";
auto i = vs.begin();
os << "[" << *i;
for (++i; i != vs.end(); ++i) os << " " << *i;
return os << "]";
}
template<class T> istream& operator>>(istream& is, vector<T>& vs) {
for (auto it = vs.begin(); it != vs.end(); it++) is >> *it;
return is;
}
int N;
void input() {
cin >> N;
}
int cache[101];
bool win(int n) {
if (cache[n] >= 0) return bool(cache[n]);
int x, y, z;
// div 2
x = n / 2;
y = n - x;
if (win(x) ^ win(y) == 0) return cache[n] = true;
// div 3
x = n / 3;
y = (n - x) / 2;
z = n - x - y;
if (win(x) ^ win(y) ^ win(z) == 0) return cache[n] = true;
return cache[n] = false;
}
void solve() {
memset(cache, -1, sizeof(cache));
cache[1] = false;
cache[2] = true;
cache[3] = true;
cout << (win(N) ? "A" : "B") << endl;
}
}
int main() {
input(); solve();
return 0;
}
izuru_matsuura