結果

問題 No.782 マイナス進数
ユーザー prd_xxxprd_xxx
提出日時 2019-01-11 22:05:37
言語 Python3
(3.10.1 + numpy 1.22.3 + scipy 1.8.0)
結果
AC  
実行時間 145 ms / 2,000 ms
コード長 311 bytes
コンパイル時間 63 ms
使用メモリ 8,440 KB
最終ジャッジ日時 2023-01-06 12:13:47
合計ジャッジ時間 4,679 ms
ジャッジサーバーID
(参考情報)
judge12 / judge16
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
使用メモリ
testcase_00 AC 15 ms
7,624 KB
testcase_01 AC 15 ms
7,672 KB
testcase_02 AC 60 ms
8,256 KB
testcase_03 AC 65 ms
8,364 KB
testcase_04 AC 72 ms
8,360 KB
testcase_05 AC 63 ms
8,440 KB
testcase_06 AC 59 ms
8,224 KB
testcase_07 AC 83 ms
8,300 KB
testcase_08 AC 66 ms
8,192 KB
testcase_09 AC 60 ms
8,312 KB
testcase_10 AC 60 ms
8,360 KB
testcase_11 AC 84 ms
8,236 KB
testcase_12 AC 76 ms
8,276 KB
testcase_13 AC 145 ms
8,268 KB
testcase_14 AC 86 ms
8,164 KB
testcase_15 AC 95 ms
8,232 KB
testcase_16 AC 86 ms
8,284 KB
testcase_17 AC 112 ms
8,276 KB
testcase_18 AC 87 ms
8,284 KB
testcase_19 AC 105 ms
8,296 KB
testcase_20 AC 85 ms
8,324 KB
testcase_21 AC 109 ms
8,148 KB
testcase_22 AC 91 ms
8,148 KB
testcase_23 AC 78 ms
8,300 KB
testcase_24 AC 136 ms
8,088 KB
testcase_25 AC 84 ms
8,352 KB
testcase_26 AC 97 ms
8,264 KB
testcase_27 AC 91 ms
8,320 KB
testcase_28 AC 83 ms
8,392 KB
testcase_29 AC 15 ms
7,792 KB
testcase_30 AC 15 ms
7,628 KB
testcase_31 AC 15 ms
7,680 KB
testcase_32 AC 15 ms
7,592 KB
testcase_33 AC 15 ms
7,732 KB
testcase_34 AC 16 ms
7,692 KB
testcase_35 AC 15 ms
7,744 KB
testcase_36 AC 15 ms
7,688 KB
testcase_37 AC 15 ms
7,688 KB
権限があれば一括ダウンロードができます

ソースコード

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