結果

問題 No.153 石の山
ユーザー Hachimori
提出日時 2015-02-16 01:01:56
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 690 bytes
コンパイル時間 506 ms
コンパイル使用メモリ 55,388 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-10-14 14:03:18
合計ジャッジ時間 1,459 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
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 * 10] = {};
    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 * 10; ++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