結果

問題 No.782 マイナス進数
ユーザー prd_xxxprd_xxx
提出日時 2019-01-11 22:05:37
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 159 ms / 2,000 ms
コード長 311 bytes
コンパイル時間 269 ms
コンパイル使用メモリ 12,416 KB
実行使用メモリ 11,136 KB
最終ジャッジ日時 2024-11-30 07:08:27
合計ジャッジ時間 4,682 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 36
権限があれば一括ダウンロードができます

ソースコード

diff #

T,B = map(int,input().split())
N = [int(input()) for i in range(T)]

def calc(n):
    if n==0: return '0'
    ret = ''
    while n:
        if n%(-B):
            ret += str(n%(-B))
            n -= n%(-B)
        else:
            ret += '0'
        n //= B
    return ret[::-1]

for n in N:
    print(calc(n))
0