結果

問題 No.782 マイナス進数
ユーザー silversmithsilversmith
提出日時 2019-05-01 21:07:18
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 264 ms / 2,000 ms
コード長 421 bytes
コンパイル時間 137 ms
コンパイル使用メモリ 10,792 KB
実行使用メモリ 8,848 KB
最終ジャッジ日時 2023-08-30 04:28:09
合計ジャッジ時間 5,779 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
7,868 KB
testcase_01 AC 16 ms
7,808 KB
testcase_02 AC 82 ms
8,732 KB
testcase_03 AC 94 ms
8,764 KB
testcase_04 AC 112 ms
8,692 KB
testcase_05 AC 87 ms
8,788 KB
testcase_06 AC 85 ms
8,848 KB
testcase_07 AC 143 ms
8,684 KB
testcase_08 AC 91 ms
8,676 KB
testcase_09 AC 84 ms
8,848 KB
testcase_10 AC 84 ms
8,696 KB
testcase_11 AC 139 ms
8,668 KB
testcase_12 AC 125 ms
8,732 KB
testcase_13 AC 261 ms
8,740 KB
testcase_14 AC 125 ms
8,776 KB
testcase_15 AC 138 ms
8,824 KB
testcase_16 AC 124 ms
8,700 KB
testcase_17 AC 196 ms
8,752 KB
testcase_18 AC 123 ms
8,848 KB
testcase_19 AC 166 ms
8,832 KB
testcase_20 AC 131 ms
8,740 KB
testcase_21 AC 188 ms
8,772 KB
testcase_22 AC 141 ms
8,756 KB
testcase_23 AC 118 ms
8,776 KB
testcase_24 AC 264 ms
8,668 KB
testcase_25 AC 124 ms
8,688 KB
testcase_26 AC 155 ms
8,684 KB
testcase_27 AC 145 ms
8,720 KB
testcase_28 AC 123 ms
8,784 KB
testcase_29 AC 16 ms
7,772 KB
testcase_30 AC 16 ms
7,932 KB
testcase_31 AC 16 ms
7,852 KB
testcase_32 AC 17 ms
7,900 KB
testcase_33 AC 16 ms
7,800 KB
testcase_34 AC 16 ms
7,836 KB
testcase_35 AC 17 ms
7,960 KB
testcase_36 AC 16 ms
7,840 KB
testcase_37 AC 17 ms
7,852 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

T, B = map(int,input().split())
N = [int(input()) for l in range(T)]

plusB = -B
for t in N:
    a = []
    sign = 1
    while t != 0:
        if sign > 0:
            a.append(t % plusB)
            t = (t - a[-1]) / plusB
        else:
            a.append(-t % plusB)
            t = (t +a[-1]) / plusB
        sign *=-1
    if len(a) == 0:
        print(0)
    else:
        print(''.join(map(str,map(int,a[::-1]))))
0