結果

問題 No.782 マイナス進数
ユーザー brthyyjpbrthyyjp
提出日時 2020-09-03 12:02:41
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 136 ms / 2,000 ms
コード長 341 bytes
コンパイル時間 602 ms
コンパイル使用メモリ 87,264 KB
実行使用メモリ 77,660 KB
最終ジャッジ日時 2023-08-15 00:01:21
合計ジャッジ時間 7,794 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 74 ms
71,336 KB
testcase_01 AC 72 ms
71,540 KB
testcase_02 AC 121 ms
77,424 KB
testcase_03 AC 123 ms
77,376 KB
testcase_04 AC 123 ms
77,276 KB
testcase_05 AC 120 ms
77,244 KB
testcase_06 AC 122 ms
77,240 KB
testcase_07 AC 124 ms
77,200 KB
testcase_08 AC 121 ms
77,324 KB
testcase_09 AC 126 ms
77,280 KB
testcase_10 AC 129 ms
77,412 KB
testcase_11 AC 129 ms
77,336 KB
testcase_12 AC 129 ms
77,404 KB
testcase_13 AC 133 ms
77,416 KB
testcase_14 AC 126 ms
77,252 KB
testcase_15 AC 126 ms
77,420 KB
testcase_16 AC 127 ms
77,300 KB
testcase_17 AC 132 ms
77,296 KB
testcase_18 AC 125 ms
77,420 KB
testcase_19 AC 129 ms
77,416 KB
testcase_20 AC 126 ms
77,400 KB
testcase_21 AC 130 ms
77,440 KB
testcase_22 AC 128 ms
77,484 KB
testcase_23 AC 123 ms
77,416 KB
testcase_24 AC 136 ms
77,484 KB
testcase_25 AC 122 ms
77,484 KB
testcase_26 AC 125 ms
77,172 KB
testcase_27 AC 124 ms
77,660 KB
testcase_28 AC 125 ms
77,400 KB
testcase_29 AC 77 ms
71,460 KB
testcase_30 AC 74 ms
71,288 KB
testcase_31 AC 77 ms
71,476 KB
testcase_32 AC 80 ms
75,900 KB
testcase_33 AC 75 ms
71,344 KB
testcase_34 AC 74 ms
71,360 KB
testcase_35 AC 74 ms
71,276 KB
testcase_36 AC 75 ms
71,316 KB
testcase_37 AC 78 ms
71,136 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

t, b = map(int, input().split())
for _ in range(t):
    n = int(input())
    if n == 0:
        print(0)
        continue
    ans = []
    while n != 0:
        r = n%(-b)
        if r != 0:
            n -= r
            ans.append(str(r))
        else:
            ans.append('0')
        n //= b
    ans.reverse()
    print(''.join(ans))
0