結果
| 問題 |
No.3112 Decrement or Mod Game
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-04-18 21:31:31 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
MLE
|
| 実行時間 | - |
| コード長 | 717 bytes |
| コンパイル時間 | 1,226 ms |
| コンパイル使用メモリ | 85,708 KB |
| 実行使用メモリ | 814,592 KB |
| 最終ジャッジ日時 | 2025-04-18 21:31:36 |
| 合計ジャッジ時間 | 4,260 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | -- * 3 |
| other | MLE * 1 -- * 64 |
ソースコード
#include <iostream>
#include <unordered_map>
using namespace std;
using ll = long long;
unordered_map<ll, unordered_map<ll, bool>> memo;
bool win(ll a, ll b) {
if (a == 0) return true; // 自分の数が0 → 勝ち
if (b == 0) return false; // 相手が0で自分が非0 → 相手の勝ち
if (memo.count(a) && memo[a].count(b)) return memo[a][b];
// 1. 操作1(1 減らす)
if (!win(b, a - 1)) return memo[a][b] = true;
// 2. 操作2(a >= b のときのみ)
if (a >= b && !win(b, a % b)) return memo[a][b] = true;
return memo[a][b] = false;
}
int main() {
ll A, B;
cin >> A >> B;
if (win(A, B)) cout << "Alice" << endl;
else cout << "Bob" << endl;
}