結果
| 問題 | No.2766 Delicious Multiply Spice |
| コンテスト | |
| ユーザー |
june19312
|
| 提出日時 | 2024-05-31 21:54:04 |
| 言語 | PyPy3 (7.3.17) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 856 bytes |
| 記録 | |
| コンパイル時間 | 379 ms |
| コンパイル使用メモリ | 85,376 KB |
| 実行使用メモリ | 52,480 KB |
| 最終ジャッジ日時 | 2026-05-27 18:32:10 |
| 合計ジャッジ時間 | 2,859 ms |
|
ジャッジサーバーID (参考情報) |
judge2_0 / judge3_1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | WA * 8 |
| other | WA * 31 |
ソースコード
import sys
sys.setrecursionlimit(10**6)
import pypyjit
pypyjit.set_param('max_unroll_recursion=-1')
N = int(input())
ans = []
while N > 1:
if N%2 == 0:
ans.append("B")
N-=1
N//=3
else:
ans.append("A")
N -= 1
if N % 2 == 0:
N//=2
else:
N//3
ans.reverse()
print("".join(ans))
def dfs(x,y):
if x <= 1:
if x == 1:
print("".join(y[::-1]))
exit()
else:
return
if (x-1)%2 == 0 and (x-1)%3 == 0:
y.append("B")
dfs((x-1)//3,y)
y.pop()
else:
return
if (x-1)%2 == 0:
y.append("A")
dfs((x-1)//2,y)
y.pop()
else:
return
if (x-1)%3 == 0:
y.append("B")
dfs((x-1)//3,y)
y.pop()
else:
return
dfs(N,[])
june19312