結果

問題 No.153 石の山
ユーザー Hachimori
提出日時 2015-02-16 00:59:17
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 680 bytes
コンパイル時間 436 ms
コンパイル使用メモリ 56,932 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2024-10-14 14:03:16
合計ジャッジ時間 1,341 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 18 WA * 9
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int rec(int, int*)’:
main.cpp:28:1: warning: control reaches end of non-void function [-Wreturn-type]
   28 | }
      | ^

ソースコード

diff #

#include<iostream>
#include<cstring>
using namespace std;
const int BUF = 105;


int N;

void read() {
    cin >> N;
}


int rec(int n, int dp[BUF]) {
    if (n == 0) return 1;
    if (n == 1) return 0;
    
    int &ret = dp[n];
    if (ret != -1) return ret;
    
    bool S[BUF] = {};
    S[rec(n / 2, dp) ^ rec((n + 1) / 2, dp)] = true;
    S[rec(n / 3, dp) ^ rec((n + 1) / 3, dp) ^ rec((n + 2) / 3, dp)] = true;
    
    for (int i = 0; i < BUF; ++i)
        if (!S[i])
            return ret = i;
}


void work() {
    int dp[BUF];
    memset(dp, - 1, sizeof(dp));

    cout << (rec(N, dp) == 0 ? 'B' : 'A') << endl;
}


int main() {
    read();
    work();
    return 0;
}
0