結果

問題 No.153 石の山
ユーザー nebukuro09nebukuro09
提出日時 2016-09-29 13:58:09
言語 Python2
(2.7.18)
結果
WA  
実行時間 -
コード長 322 bytes
コンパイル時間 190 ms
コンパイル使用メモリ 6,944 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-05-01 07:41:34
合計ジャッジ時間 1,390 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 10 ms
6,528 KB
testcase_01 AC 10 ms
6,400 KB
testcase_02 WA -
testcase_03 AC 10 ms
6,528 KB
testcase_04 AC 10 ms
6,528 KB
testcase_05 AC 11 ms
6,400 KB
testcase_06 AC 10 ms
6,400 KB
testcase_07 AC 9 ms
6,400 KB
testcase_08 AC 10 ms
6,400 KB
testcase_09 AC 10 ms
6,400 KB
testcase_10 WA -
testcase_11 AC 10 ms
6,400 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 10 ms
6,528 KB
testcase_16 AC 10 ms
6,528 KB
testcase_17 AC 9 ms
6,528 KB
testcase_18 AC 9 ms
6,528 KB
testcase_19 AC 10 ms
6,528 KB
testcase_20 AC 9 ms
6,400 KB
testcase_21 AC 9 ms
6,400 KB
testcase_22 AC 9 ms
6,400 KB
testcase_23 WA -
testcase_24 AC 9 ms
6,400 KB
testcase_25 WA -
testcase_26 AC 10 ms
6,528 KB
testcase_27 AC 9 ms
6,272 KB
testcase_28 AC 9 ms
6,528 KB
testcase_29 WA -
testcase_30 AC 9 ms
6,528 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N = input()
if N == 1:
    print 'B'
    exit()
grundy = [0 for _ in xrange(N+1)]
grundy[2] = 1

for i in xrange(3, N+1):
    m1 = grundy[i/3] ^ grundy[i/3+(i%3==1)] ^ grundy[i/3+(i%3==2)]
    m2 = grundy[i/2] ^ grundy[i/2+(i%2==1)]
    while grundy[i] in (m1, m2):
        grundy[i] += 1

print 'A' if grundy[N] else 'B'
0