結果

問題 No.2766 Delicious Multiply Spice
ユーザー timi
提出日時 2024-06-02 05:12:57
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 45 ms / 2,000 ms
コード長 471 bytes
コンパイル時間 258 ms
コンパイル使用メモリ 82,304 KB
実行使用メモリ 52,480 KB
最終ジャッジ日時 2024-12-22 22:47:18
合計ジャッジ時間 3,372 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 8
other AC * 31
権限があれば一括ダウンロードができます

ソースコード

diff #

#ax,ay,az=map(int, input().split())
#bx,by,bz=map(int, input().split())

N=int(input())
D={}
import heapq 
A=[]
heapq.heappush(A,(N,0)) 
while A:
  x,c=heapq.heappop(A)
  D[x]=c 
  if x==1:
    break
  if (x-1)%2==0:
    p=(x-1)//2 
    q=c*3+1 
    heapq.heappush(A,(p,q))
  if (x-1)%3==0:
    p=(x-1)//3 
    q=c*3+2
    heapq.heappush(A,(p,q))
    
c=D[1]
ans=[]
while c:
  if c%3==1:
    ans.append('A')
  elif c%3==2:
    ans.append('B')
  c//=3 
print(''.join(ans))
0