結果
問題 | No.153 石の山 |
ユーザー |
![]() |
提出日時 | 2020-12-07 22:15:40 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 42 ms / 5,000 ms |
コード長 | 891 bytes |
コンパイル時間 | 223 ms |
コンパイル使用メモリ | 82,120 KB |
実行使用メモリ | 54,172 KB |
最終ジャッジ日時 | 2024-09-17 14:04:55 |
合計ジャッジ時間 | 2,354 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 27 |
ソースコード
import syssys.setrecursionlimit(10**7)def I(): return int(sys.stdin.readline().rstrip())def MI(): return map(int,sys.stdin.readline().rstrip().split())def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))def LI2(): return list(map(int,sys.stdin.readline().rstrip()))def S(): return sys.stdin.readline().rstrip()def LS(): return list(sys.stdin.readline().rstrip().split())def LS2(): return list(sys.stdin.readline().rstrip())N = I()Grundy = [-1]*(N+1)Grundy[1] = 0for i in range(2,N+1):X = set()if i % 2 == 0:X.add(0)else:X.add(Grundy[i//2] ^ Grundy[i//2+1])if i % 3 == 0:X.add(Grundy[i//3])elif i % 3 == 1:X.add(Grundy[i//3+1])else:X.add(Grundy[i//3])for j in range(100):if not j in X:Grundy[i] = jbreakprint('A' if Grundy[-1] != 0 else 'B')