結果

問題 No.782 マイナス進数
ユーザー 👑 rin204rin204
提出日時 2022-09-30 23:10:30
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 157 ms / 2,000 ms
コード長 364 bytes
コンパイル時間 304 ms
コンパイル使用メモリ 82,188 KB
実行使用メモリ 77,056 KB
最終ジャッジ日時 2024-12-23 00:52:58
合計ジャッジ時間 7,137 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 36
権限があれば一括ダウンロードができます

ソースコード

diff #

t, b = map(int, input().split())

def solve(n):
    if n == 0:
        print(0)
        return

    A = []
    x = 1
    y = abs(b)
    while n != 0:
        c = 0
        while n % y != 0:
            c += 1
            n -= x
        A.append(c)
        x *= b
        y *= abs(b)
    print(*A[::-1], sep="")

for _ in range(t):
    n = int(input())
    solve(n)
0