結果

問題 No.782 マイナス進数
ユーザー もりをもりを
提出日時 2019-01-11 21:34:23
言語 Python3
(3.10.1 + numpy 1.22.3 + scipy 1.8.0)
結果
AC  
実行時間 245 ms / 2,000 ms
コード長 421 bytes
コンパイル時間 62 ms
使用メモリ 7,788 KB
最終ジャッジ日時 2023-01-06 09:41:42
合計ジャッジ時間 5,856 ms
ジャッジサーバーID
(参考情報)
judge11 / judge16
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
使用メモリ
testcase_00 AC 14 ms
7,776 KB
testcase_01 AC 14 ms
7,540 KB
testcase_02 AC 97 ms
7,544 KB
testcase_03 AC 108 ms
7,696 KB
testcase_04 AC 118 ms
7,548 KB
testcase_05 AC 101 ms
7,584 KB
testcase_06 AC 97 ms
7,724 KB
testcase_07 AC 147 ms
7,700 KB
testcase_08 AC 106 ms
7,636 KB
testcase_09 AC 97 ms
7,788 KB
testcase_10 AC 100 ms
7,752 KB
testcase_11 AC 143 ms
7,752 KB
testcase_12 AC 130 ms
7,692 KB
testcase_13 AC 245 ms
7,548 KB
testcase_14 AC 136 ms
7,740 KB
testcase_15 AC 146 ms
7,640 KB
testcase_16 AC 136 ms
7,552 KB
testcase_17 AC 188 ms
7,696 KB
testcase_18 AC 138 ms
7,560 KB
testcase_19 AC 168 ms
7,752 KB
testcase_20 AC 135 ms
7,544 KB
testcase_21 AC 178 ms
7,748 KB
testcase_22 AC 140 ms
7,696 KB
testcase_23 AC 125 ms
7,740 KB
testcase_24 AC 234 ms
7,584 KB
testcase_25 AC 138 ms
7,564 KB
testcase_26 AC 155 ms
7,564 KB
testcase_27 AC 143 ms
7,552 KB
testcase_28 AC 133 ms
7,636 KB
testcase_29 AC 14 ms
7,544 KB
testcase_30 AC 15 ms
7,568 KB
testcase_31 AC 15 ms
7,544 KB
testcase_32 AC 15 ms
7,532 KB
testcase_33 AC 15 ms
7,668 KB
testcase_34 AC 14 ms
7,624 KB
testcase_35 AC 15 ms
7,672 KB
testcase_36 AC 15 ms
7,616 KB
testcase_37 AC 15 ms
7,548 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

t,b = map(int,input().split())
for _ in range(t):
    n = int(input())
    if n == 0:
        print(0)
        continue
    ans = []
    # cnt = 0####
    while n != 0:
        t = (n % b)
        n //= b
        if t < 0:
            n += 1
            t -= b
        # print(n,t,ans)
        # cnt += 1######
        # if cnt == 20:####
        #     break#####
        ans.append(str(t))
    print(''.join(ans[::-1]))
0