結果

問題 No.782 マイナス進数
ユーザー kohei2019kohei2019
提出日時 2022-04-09 12:20:32
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 156 ms / 2,000 ms
コード長 655 bytes
コンパイル時間 339 ms
コンパイル使用メモリ 86,932 KB
実行使用メモリ 78,440 KB
最終ジャッジ日時 2023-08-19 16:08:44
合計ジャッジ時間 6,567 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 63 ms
70,992 KB
testcase_01 AC 62 ms
71,228 KB
testcase_02 AC 156 ms
77,848 KB
testcase_03 AC 123 ms
77,648 KB
testcase_04 AC 126 ms
77,768 KB
testcase_05 AC 125 ms
77,712 KB
testcase_06 AC 129 ms
77,692 KB
testcase_07 AC 128 ms
77,928 KB
testcase_08 AC 128 ms
77,648 KB
testcase_09 AC 134 ms
77,392 KB
testcase_10 AC 131 ms
77,484 KB
testcase_11 AC 131 ms
78,284 KB
testcase_12 AC 130 ms
77,860 KB
testcase_13 AC 140 ms
78,140 KB
testcase_14 AC 130 ms
77,600 KB
testcase_15 AC 131 ms
77,644 KB
testcase_16 AC 143 ms
77,696 KB
testcase_17 AC 146 ms
78,440 KB
testcase_18 AC 140 ms
77,492 KB
testcase_19 AC 131 ms
77,900 KB
testcase_20 AC 131 ms
78,388 KB
testcase_21 AC 150 ms
78,156 KB
testcase_22 AC 127 ms
77,824 KB
testcase_23 AC 124 ms
77,724 KB
testcase_24 AC 148 ms
78,224 KB
testcase_25 AC 134 ms
77,816 KB
testcase_26 AC 133 ms
77,760 KB
testcase_27 AC 130 ms
77,708 KB
testcase_28 AC 131 ms
77,652 KB
testcase_29 AC 66 ms
75,732 KB
testcase_30 AC 67 ms
75,852 KB
testcase_31 AC 71 ms
75,956 KB
testcase_32 AC 78 ms
76,672 KB
testcase_33 AC 67 ms
75,536 KB
testcase_34 AC 67 ms
75,936 KB
testcase_35 AC 70 ms
76,212 KB
testcase_36 AC 73 ms
75,796 KB
testcase_37 AC 70 ms
75,992 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

T,B = map(int,input().split())
A = abs(B)
for i in range(T):
    N = int(input())
    if N == 0:
        print(0)
        continue
    ls = []
    while N > 0:
        ls.append(N%A)
        N //= A
    ls2 = [0]*40
    for j in range(len(ls)):
        ls2[j] = ls[j]
    for j in range(39):
        if j % 2 == 0:
            ls2[j+1] += ls2[j]//A
            ls2[j] = ls2[j]%A
        else:
            ls2[j+1] += ls2[j]//A
            ls2[j] = ls2[j]%A
            if not ls2[j]==0:
                ls2[j] = A-ls2[j]
                ls2[j+1] += 1
    while ls2[-1] == 0:
        ls2.pop()
    ls2.reverse()
    print(*ls2,sep='')
            
        
0