結果

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

ソースコード

diff #

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

def calc(N):
    l = []
    while N:
        r = N % (-B)
        l.append(str(r))
        N = (N - r) // B
    return "".join(reversed(l))
for _ in range(T):
    N = int(input())
    if N == 0:print(0)
    else:
        print(calc(N))
0