結果

問題 No.153 石の山
ユーザー takeya_okinotakeya_okino
提出日時 2017-07-17 12:34:36
言語 PHP
(8.3.4)
結果
AC  
実行時間 40 ms / 5,000 ms
コード長 531 bytes
コンパイル時間 156 ms
コンパイル使用メモリ 32,144 KB
実行使用メモリ 31,116 KB
最終ジャッジ日時 2024-04-16 23:50:17
合計ジャッジ時間 2,176 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 40 ms
30,796 KB
testcase_01 AC 40 ms
30,948 KB
testcase_02 AC 40 ms
31,112 KB
testcase_03 AC 40 ms
30,808 KB
testcase_04 AC 38 ms
31,080 KB
testcase_05 AC 39 ms
30,792 KB
testcase_06 AC 39 ms
30,940 KB
testcase_07 AC 38 ms
30,908 KB
testcase_08 AC 39 ms
30,836 KB
testcase_09 AC 39 ms
30,652 KB
testcase_10 AC 38 ms
30,704 KB
testcase_11 AC 40 ms
31,040 KB
testcase_12 AC 39 ms
30,672 KB
testcase_13 AC 36 ms
30,676 KB
testcase_14 AC 36 ms
31,044 KB
testcase_15 AC 36 ms
30,792 KB
testcase_16 AC 36 ms
30,832 KB
testcase_17 AC 38 ms
30,912 KB
testcase_18 AC 38 ms
30,848 KB
testcase_19 AC 38 ms
30,956 KB
testcase_20 AC 39 ms
30,828 KB
testcase_21 AC 38 ms
30,712 KB
testcase_22 AC 37 ms
31,044 KB
testcase_23 AC 38 ms
30,956 KB
testcase_24 AC 37 ms
30,604 KB
testcase_25 AC 35 ms
31,116 KB
testcase_26 AC 34 ms
30,940 KB
testcase_27 AC 36 ms
31,032 KB
testcase_28 AC 36 ms
30,832 KB
testcase_29 AC 37 ms
30,952 KB
testcase_30 AC 36 ms
30,700 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
No syntax errors detected in Main.php

ソースコード

diff #

<?php
$N = trim(fgets(STDIN));
$dp = array();
$dp[1] = 0;
$dp[2] = 1;
for($i = 3; $i <= $N; $i++) {
  $grundy1 = 0;
  $grundy2 = 0;
  $m = intdiv($i, 2);
  $grundy1 = $dp[$m] ^ $dp[($i - $m)];
  $n1 = intdiv($i, 3);
  $n2 = intdiv($i - $n1, 2);
  $n3 = $i - $n1 - $n2;
  $grundy2 = $dp[$n1] ^ $dp[$n2] ^ $dp[$n3];
  if(($grundy1 != 0) && ($grundy2 != 0)) {
    $dp[$i] = 0;
  } else if(($grundy1 != 1) && ($grundy2 != 1)) {
    $dp[$i] = 1;
  } else {
    $dp[$i] = 2;
  }
}
$ans = 'A';
if($dp[$N] == 0) $ans = 'B';
print($ans);
?>
0