結果

問題 No.782 マイナス進数
ユーザー pasoconhoshiipasoconhoshii
提出日時 2019-03-18 23:52:12
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 282 ms / 2,000 ms
コード長 458 bytes
コンパイル時間 383 ms
コンパイル使用メモリ 10,668 KB
実行使用メモリ 7,976 KB
最終ジャッジ日時 2023-09-26 14:08:40
合計ジャッジ時間 6,543 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
7,956 KB
testcase_01 AC 16 ms
7,856 KB
testcase_02 AC 119 ms
7,796 KB
testcase_03 AC 128 ms
7,900 KB
testcase_04 AC 133 ms
7,904 KB
testcase_05 AC 113 ms
7,772 KB
testcase_06 AC 110 ms
7,800 KB
testcase_07 AC 158 ms
7,828 KB
testcase_08 AC 119 ms
7,832 KB
testcase_09 AC 110 ms
7,772 KB
testcase_10 AC 110 ms
7,848 KB
testcase_11 AC 160 ms
7,756 KB
testcase_12 AC 146 ms
7,920 KB
testcase_13 AC 282 ms
7,772 KB
testcase_14 AC 160 ms
7,772 KB
testcase_15 AC 169 ms
7,976 KB
testcase_16 AC 146 ms
7,824 KB
testcase_17 AC 202 ms
7,832 KB
testcase_18 AC 148 ms
7,788 KB
testcase_19 AC 179 ms
7,808 KB
testcase_20 AC 147 ms
7,836 KB
testcase_21 AC 194 ms
7,820 KB
testcase_22 AC 154 ms
7,796 KB
testcase_23 AC 139 ms
7,852 KB
testcase_24 AC 252 ms
7,900 KB
testcase_25 AC 147 ms
7,852 KB
testcase_26 AC 169 ms
7,800 KB
testcase_27 AC 155 ms
7,836 KB
testcase_28 AC 148 ms
7,852 KB
testcase_29 AC 16 ms
7,876 KB
testcase_30 AC 16 ms
7,948 KB
testcase_31 AC 16 ms
7,832 KB
testcase_32 AC 17 ms
7,912 KB
testcase_33 AC 16 ms
7,848 KB
testcase_34 AC 17 ms
7,812 KB
testcase_35 AC 16 ms
7,852 KB
testcase_36 AC 15 ms
7,808 KB
testcase_37 AC 16 ms
7,960 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

T,B = map(int, input().split())

for i in range(T):
    n = int(input())
    if n == 0:
        print(0)
        continue
    ans = []
    t = B
    while n!=0: 
        p = n % t
        if p >= 0:
            ans.append( n % t )
            n //= t
        else:
            ans.append( n % t - t )
            n = (n//t)+1
        
        # t *= B
    ans = list(reversed(ans))
    ans = list(map(str, ans))
    print("".join(ans))
            
        
0