結果

問題 No.3112 Decrement or Mod Game
ユーザー aaaaaaaaaaa
提出日時 2025-04-19 10:53:18
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 562 bytes
コンパイル時間 714 ms
コンパイル使用メモリ 70,832 KB
実行使用メモリ 7,844 KB
最終ジャッジ日時 2025-04-19 10:53:21
合計ジャッジ時間 3,064 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2 WA * 1
other AC * 43 WA * 22
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <algorithm>

using namespace std;

bool canWin(long long a, long long b, bool isAliceTurn) {
    if (a == 0 || b == 0) return false;
    
    if (a < b) swap(a, b);
    
    if (a % b == 0) return true;
    
    if (a >= 2 * b) return true;
    
    return !canWin(b, a - b, !isAliceTurn);
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    long long A, B;
    cin >> A >> B;

    if (canWin(A, B, true)) {
        cout << "Alice" << endl;
    } else {
        cout << "Bob" << endl;
    }

    return 0;
}
0