結果

問題 No.782 マイナス進数
ユーザー 👑 maimai
提出日時 2019-01-11 21:56:09
言語 Ruby
(3.1.1p18 )
結果
AC  
実行時間 347 ms / 2,000 ms
コード長 309 bytes
コンパイル時間 34 ms
使用メモリ 14,060 KB
最終ジャッジ日時 2023-01-06 11:16:59
合計ジャッジ時間 7,780 ms
ジャッジサーバーID
(参考情報)
judge10 / judge16
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
使用メモリ
testcase_00 AC 71 ms
13,832 KB
testcase_01 AC 71 ms
13,832 KB
testcase_02 AC 121 ms
13,980 KB
testcase_03 AC 135 ms
13,796 KB
testcase_04 AC 153 ms
13,724 KB
testcase_05 AC 127 ms
13,948 KB
testcase_06 AC 122 ms
13,812 KB
testcase_07 AC 193 ms
13,892 KB
testcase_08 AC 136 ms
13,860 KB
testcase_09 AC 121 ms
13,848 KB
testcase_10 AC 121 ms
13,792 KB
testcase_11 AC 189 ms
13,976 KB
testcase_12 AC 172 ms
13,732 KB
testcase_13 AC 347 ms
14,004 KB
testcase_14 AC 172 ms
13,948 KB
testcase_15 AC 187 ms
13,868 KB
testcase_16 AC 172 ms
13,800 KB
testcase_17 AC 259 ms
13,800 KB
testcase_18 AC 175 ms
13,868 KB
testcase_19 AC 221 ms
13,852 KB
testcase_20 AC 171 ms
13,804 KB
testcase_21 AC 238 ms
13,972 KB
testcase_22 AC 181 ms
13,804 KB
testcase_23 AC 156 ms
13,944 KB
testcase_24 AC 338 ms
13,796 KB
testcase_25 AC 170 ms
13,800 KB
testcase_26 AC 206 ms
13,988 KB
testcase_27 AC 189 ms
13,948 KB
testcase_28 AC 166 ms
13,800 KB
testcase_29 AC 71 ms
13,828 KB
testcase_30 AC 72 ms
13,904 KB
testcase_31 AC 75 ms
14,060 KB
testcase_32 AC 74 ms
13,892 KB
testcase_33 AC 72 ms
13,716 KB
testcase_34 AC 71 ms
13,796 KB
testcase_35 AC 71 ms
13,796 KB
testcase_36 AC 71 ms
13,852 KB
testcase_37 AC 71 ms
14,004 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.rb:15: warning: assigned but unused variable - q
Syntax OK

ソースコード

diff #

def ascan; gets.split.map(&:to_i); end

T,B = ascan

T.times do
    n = gets.to_i
    if n == 0
        p 0
        next
    end
    
    l = ""
    i = 0
    while n != 0
        q, md = n.divmod(-B**(i+1))
        n-=md
        l += (md/(-B**(i))).to_s[-1]
        i += 1
    end
    
    puts l.reverse
end
0