結果

問題 No.153 石の山
ユーザー pop_o
提出日時 2024-08-31 14:53:29
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 723 bytes
コンパイル時間 2,198 ms
コンパイル使用メモリ 170,368 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-08-31 14:53:32
合計ジャッジ時間 3,439 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 19 WA * 8
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int n; 
    cin >> n;
    vector<int> memo(n+1, -1);
    auto g = [&] (auto self, int i) -> int {
        if (memo[i] != -1) return memo[i];
        if (i == 0 || i == 1) return memo[i] = 0;
        set<int> st;
        int res = 0;
        if (i % 3 == 1) {
            res = self(self, i/3 + 1);
        } else {
            res = self(self, i/3);
        }
        if (res == 0) return memo[i] = 1;
        res = 0;
        if (i & 1) {
            res = i^(i-1);
        } else {
            res = 0;
        }
        return memo[i] = res;
    };
    cout << (g(g, n) == 0 ? "B": "A") << "\n";
}
0