結果
| 問題 |
No.2766 Delicious Multiply Spice
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-05-31 23:03:44 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 468 bytes |
| コンパイル時間 | 264 ms |
| コンパイル使用メモリ | 82,656 KB |
| 実行使用メモリ | 54,812 KB |
| 最終ジャッジ日時 | 2024-12-21 01:18:27 |
| 合計ジャッジ時間 | 3,191 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 8 |
| other | AC * 13 WA * 18 |
ソースコード
n=int(input())
d={1:0}
INF=1<<60
def f(x):
if x in d:
return d[x]
d[x]=INF
if (x-1)%2==0:
nx=(x-1)//2
if (nx-1)%2==0 or (nx-1)%3==0:
d[x]=min(d[x],f((x-1)//2)+1)
if (x-1)%3==0:
nx=(x-1)//3
if (nx-1)%2==0 or (nx-1)%3==0:
d[x]=min(d[x],f((x-1)//3)+1)
return d[x]
f(n)
c=[0]*len(d)
for k,v in d.items():
if v!=INF:
c[v]=k
ans=[]
for i,j in zip(c,c[1:]):
if i*2+1==j:
ans+='A',
else:
ans+='B',
print(*ans,sep='')