結果
問題 | No.153 石の山 |
ユーザー |
|
提出日時 | 2023-12-29 23:06:17 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 663 bytes |
コンパイル時間 | 558 ms |
コンパイル使用メモリ | 82,276 KB |
実行使用メモリ | 63,516 KB |
最終ジャッジ日時 | 2024-09-27 16:24:17 |
合計ジャッジ時間 | 3,464 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 20 WA * 7 |
ソースコード
from collections import *from itertools import *from functools import *from heapq import *import sys,math,time,randominput = sys.stdin.readlineN = int(input())mem = [-1]*(N+1)def f(x):if mem[x]!=-1:return mem[x]if x%2==0:mem[x] = 1return 1if x==1:mem[x] = 0return mem[x]X = []n = x//2if n%2==0:X.append(f(n+1))else:X.append(f(n))n = x//3if x%3==0:X.append(f(n))elif x%3==1:X.append(f(n+1))else:X.append(f(n))mem[x] = 1 - min(X)return mem[x]if f(N):print('A')else:print('B')