結果

問題 No.2787 グッドスタイン数列?
コンテスト
ユーザー ir5
提出日時 2024-06-15 19:58:42
言語 PyPy3
(7.3.17)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
AC  
実行時間 35 ms / 2,000 ms
コード長 715 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 162 ms
コンパイル使用メモリ 85,900 KB
実行使用メモリ 54,372 KB
最終ジャッジ日時 2026-03-06 03:29:39
合計ジャッジ時間 3,316 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 55
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

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()
0