結果

問題 No.782 マイナス進数
ユーザー H3PO4
提出日時 2021-02-03 12:57:36
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 215 ms / 2,000 ms
コード長 323 bytes
コンパイル時間 242 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 10,752 KB
最終ジャッジ日時 2024-06-30 00:23:52
合計ジャッジ時間 5,738 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 36
権限があれば一括ダウンロードができます

ソースコード

diff #

T, B = map(int, input().split())


def solve(N):
    lst = []
    while N:
        N, m = divmod(N, B)
        if m < 0:
            m -= B
            N += 1
        lst.append(m)
    res = ''.join(map(str, reversed(lst)))
    if not res:
        res = 0
    return res


for _ in range(T):
    print(solve(int(input())))
0