結果
問題 |
No.2787 グッドスタイン数列?
|
ユーザー |
|
提出日時 | 2024-06-15 19:58:42 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 49 ms / 2,000 ms |
コード長 | 715 bytes |
コンパイル時間 | 613 ms |
コンパイル使用メモリ | 82,432 KB |
実行使用メモリ | 52,352 KB |
最終ジャッジ日時 | 2024-06-15 19:58:47 |
合計ジャッジ時間 | 4,762 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 55 |
ソースコード
def main(): n, b, c = list(map(int, input().split())) a = [] while n > 0: a.append(n % b) n = int(n // b) a = list(reversed(a)) it = 0 while len(a) > 0 and it <= c: if a[0] == 0: del a[0] continue if a[-1] == 0: it += 1 for i in range(1, len(a) + 1): if a[-i] != 0: a[-i] -= 1 break a[-i] = b b += 1 continue it += a[-1] b += a[-1] a[-1] = 0 print("Yes") it = it * 2 + 2 if it > c: print("No") else: print("Yes") print(it) # experiment() main()