結果

問題 No.782 マイナス進数
ユーザー tktk_snsntktk_snsn
提出日時 2020-12-10 12:28:20
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 163 ms / 2,000 ms
コード長 348 bytes
コンパイル時間 97 ms
コンパイル使用メモリ 12,052 KB
実行使用メモリ 11,580 KB
最終ジャッジ日時 2023-10-20 00:19:16
合計ジャッジ時間 4,718 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 29 ms
10,168 KB
testcase_01 AC 30 ms
10,168 KB
testcase_02 AC 76 ms
11,428 KB
testcase_03 AC 81 ms
11,428 KB
testcase_04 AC 87 ms
11,428 KB
testcase_05 AC 78 ms
11,428 KB
testcase_06 AC 79 ms
11,428 KB
testcase_07 AC 103 ms
11,428 KB
testcase_08 AC 81 ms
11,428 KB
testcase_09 AC 75 ms
11,428 KB
testcase_10 AC 76 ms
11,428 KB
testcase_11 AC 102 ms
11,420 KB
testcase_12 AC 97 ms
11,420 KB
testcase_13 AC 163 ms
11,580 KB
testcase_14 AC 99 ms
11,420 KB
testcase_15 AC 103 ms
11,420 KB
testcase_16 AC 99 ms
11,420 KB
testcase_17 AC 129 ms
11,580 KB
testcase_18 AC 99 ms
11,420 KB
testcase_19 AC 117 ms
11,580 KB
testcase_20 AC 99 ms
11,420 KB
testcase_21 AC 124 ms
11,576 KB
testcase_22 AC 102 ms
11,420 KB
testcase_23 AC 93 ms
11,420 KB
testcase_24 AC 160 ms
11,580 KB
testcase_25 AC 98 ms
11,420 KB
testcase_26 AC 115 ms
11,444 KB
testcase_27 AC 105 ms
11,420 KB
testcase_28 AC 97 ms
11,420 KB
testcase_29 AC 29 ms
10,168 KB
testcase_30 AC 28 ms
10,168 KB
testcase_31 AC 29 ms
10,172 KB
testcase_32 AC 30 ms
10,172 KB
testcase_33 AC 29 ms
10,168 KB
testcase_34 AC 29 ms
10,168 KB
testcase_35 AC 30 ms
10,168 KB
testcase_36 AC 29 ms
10,168 KB
testcase_37 AC 30 ms
10,172 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def convert(N, B):
    if N == 0:
        return "0"
    res = []
    while N:
        m = N % B
        if m != 0:
            N += B - m
        N //= B
        res.append(abs((B - m) % B))
    return "".join(map(str, res[::-1]))


T, B = map(int, input().split())
N = [int(input()) for _ in range(T)]
print(*[convert(n, B) for n in N], sep="\n")
0