結果

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

ソースコード

diff #

#include <iostream>
#include <algorithm> // For std::swap

bool can_win(long long a, long long b) {
    if (a == 0) {
        return false;
    }

    if (a < b) {
        return !can_win(b, a);
    }

    if (a % b == 0) {
        return true;
    }

    long long m = a / b;
    long long r = a % b; // r > 0
    return !can_win(b, r) || (m > 1);
}

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

    long long A, B;
    std::cin >> A >> B;

    if (can_win(A, B)) {
        std::cout << "Alice" << std::endl;
    } else {
        std::cout << "Bob" << std::endl;
    }
    return 0;
}
0