結果

問題 No.782 マイナス進数
ユーザー rlangevinrlangevin
提出日時 2023-02-07 00:56:10
言語 PyPy3
(7.3.13)
結果
AC  
実行時間 170 ms / 2,000 ms
コード長 480 bytes
コンパイル時間 280 ms
コンパイル使用メモリ 87,108 KB
実行使用メモリ 78,672 KB
最終ジャッジ日時 2023-09-18 10:10:16
合計ジャッジ時間 7,946 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 70 ms
71,144 KB
testcase_01 AC 76 ms
71,456 KB
testcase_02 AC 161 ms
78,336 KB
testcase_03 AC 138 ms
78,004 KB
testcase_04 AC 149 ms
78,428 KB
testcase_05 AC 136 ms
77,568 KB
testcase_06 AC 148 ms
78,648 KB
testcase_07 AC 155 ms
78,388 KB
testcase_08 AC 137 ms
77,712 KB
testcase_09 AC 149 ms
77,680 KB
testcase_10 AC 150 ms
77,612 KB
testcase_11 AC 153 ms
77,652 KB
testcase_12 AC 158 ms
78,652 KB
testcase_13 AC 170 ms
77,608 KB
testcase_14 AC 169 ms
78,488 KB
testcase_15 AC 160 ms
77,652 KB
testcase_16 AC 162 ms
78,552 KB
testcase_17 AC 163 ms
77,952 KB
testcase_18 AC 163 ms
78,672 KB
testcase_19 AC 158 ms
77,628 KB
testcase_20 AC 160 ms
77,724 KB
testcase_21 AC 152 ms
77,696 KB
testcase_22 AC 143 ms
77,628 KB
testcase_23 AC 140 ms
77,512 KB
testcase_24 AC 162 ms
77,804 KB
testcase_25 AC 139 ms
77,596 KB
testcase_26 AC 145 ms
77,672 KB
testcase_27 AC 151 ms
78,512 KB
testcase_28 AC 142 ms
77,672 KB
testcase_29 AC 74 ms
71,352 KB
testcase_30 AC 74 ms
71,604 KB
testcase_31 AC 76 ms
71,404 KB
testcase_32 AC 85 ms
76,512 KB
testcase_33 AC 73 ms
71,288 KB
testcase_34 AC 74 ms
71,412 KB
testcase_35 AC 75 ms
71,404 KB
testcase_36 AC 73 ms
71,184 KB
testcase_37 AC 74 ms
71,408 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

T, B = map(int, input().split())
B = -B
for _ in range(T):
    N = int(input())
    if N == 0:
        print(0)
        continue
    cnt = 0
    ans = []
    while N:
        v = N % B
        # print(cnt, v, N)
        if cnt % 2:
            if v:
                ans.append(B - v)
                N += B
            else:
                ans.append(0)
        else:
            ans.append(v)
        N //= B
        cnt += 1
        
    ans = ans[::-1]
    print(*ans, sep="")
0