結果

問題 No.153 石の山
ユーザー yuppe19 😺
提出日時 2015-05-06 15:34:21
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 556 bytes
コンパイル時間 1,162 ms
コンパイル使用メモリ 163,296 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-10-14 14:34:16
合計ジャッジ時間 1,951 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 27
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:24:15: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   24 |   int n; scanf("%d", &n);
      |          ~~~~~^~~~~~~~~~

ソースコード

diff #

// (ΦωΦ)<これはわからん!
#include <bits/stdc++.h>
using namespace std;

const int N = 111;
int gr[N];

int g(int n) {
  if(gr[n] > 0) { return gr[n]; }
  if(n == 1) { return gr[n] = 0; }
  set<int> sett;
  if(n >= 2) { sett.insert(g(n/2) ^ g(n/2+(n%2==1?1:0))); }
  if(n >= 3) { sett.insert(g(n/3) ^ g(n/3+(n%3==2?1:0)) ^ g(n/3+(n%3!=0?1:0))); }
  int g = 0;
  while(sett.count(g) != 0) { g++; }
  return gr[n] = g;
}

const char* f(int n) {
  return g(n) ? "A" : "B";
}

int main(void) {
  int n; scanf("%d", &n);
  puts(f(n));
  return 0;
}
0