結果

問題 No.782 マイナス進数
ユーザー mkawa2mkawa2
提出日時 2021-02-11 01:48:06
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
RE  
実行時間 -
コード長 1,124 bytes
コンパイル時間 149 ms
コンパイル使用メモリ 11,012 KB
実行使用メモリ 9,028 KB
最終ジャッジ日時 2023-09-22 22:46:08
合計ジャッジ時間 5,824 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
8,336 KB
testcase_01 AC 16 ms
8,388 KB
testcase_02 AC 65 ms
8,804 KB
testcase_03 AC 77 ms
8,968 KB
testcase_04 AC 87 ms
8,832 KB
testcase_05 AC 70 ms
8,860 KB
testcase_06 AC 70 ms
8,804 KB
testcase_07 AC 114 ms
8,976 KB
testcase_08 AC 75 ms
8,988 KB
testcase_09 AC 64 ms
8,944 KB
testcase_10 AC 66 ms
8,796 KB
testcase_11 AC 116 ms
8,904 KB
testcase_12 AC 100 ms
9,028 KB
testcase_13 AC 216 ms
9,012 KB
testcase_14 AC 100 ms
8,988 KB
testcase_15 AC 112 ms
8,820 KB
testcase_16 AC 103 ms
8,984 KB
testcase_17 AC 156 ms
8,836 KB
testcase_18 AC 100 ms
8,852 KB
testcase_19 AC 134 ms
8,872 KB
testcase_20 AC 101 ms
9,000 KB
testcase_21 AC 146 ms
8,848 KB
testcase_22 AC 110 ms
8,864 KB
testcase_23 AC 93 ms
8,892 KB
testcase_24 AC 210 ms
8,836 KB
testcase_25 AC 99 ms
9,024 KB
testcase_26 AC 126 ms
8,872 KB
testcase_27 AC 113 ms
8,944 KB
testcase_28 AC 97 ms
8,988 KB
testcase_29 RE -
testcase_30 RE -
testcase_31 RE -
testcase_32 RE -
testcase_33 RE -
testcase_34 RE -
testcase_35 RE -
testcase_36 RE -
testcase_37 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

sys.setrecursionlimit(10**6)
int1 = lambda x: int(x)-1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.buffer.readline())
def MI(): return map(int, sys.stdin.buffer.readline().split())
def MI1(): return map(int1, sys.stdin.buffer.readline().split())
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def LI1(): return list(map(int1, sys.stdin.buffer.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def BI(): return sys.stdin.buffer.readline().rstrip()
def SI(): return sys.stdin.buffer.readline().rstrip().decode()
# dij = [(0, 1), (-1, 0), (0, -1), (1, 0)]
dij = [[(-1, 0), (1, 0)], [(0, -1), (0, 1)]]
inf = 10**16
# md = 998244353
# md = 10**9+7

def conv(n):
    aa=[]
    while n:
        n,r=divmod(n,b)
        aa.append(r)
    aa+=[0]*5
    for i in range(len(aa)):
        if aa[i] == b:
            aa[i] = 0
            aa[i+1] += 1
        if i & 1 and aa[i]:
            aa[i] = b-aa[i]
            aa[i+1]+=1
    while aa[-1] == 0: aa.pop()
    print(*aa[::-1], sep="")

t, b = MI()
b = -b
for _ in range(t):
    conv(II())
0