結果

問題 No.782 マイナス進数
ユーザー kohei2019
提出日時 2022-04-09 12:19:00
言語 PyPy3
(7.3.15)
結果
RE  
実行時間 -
コード長 606 bytes
コンパイル時間 168 ms
コンパイル使用メモリ 82,152 KB
実行使用メモリ 76,908 KB
最終ジャッジ日時 2024-11-29 09:46:07
合計ジャッジ時間 6,541 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 27 RE * 9
権限があれば一括ダウンロードができます

ソースコード

diff #

T,B = map(int,input().split())
A = abs(B)
for i in range(T):
    N = int(input())
    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