結果

問題 No.782 マイナス進数
ユーザー maimai
提出日時 2019-01-11 21:56:09
言語 Ruby
(3.2.2)
結果
AC  
実行時間 332 ms / 2,000 ms
コード長 309 bytes
コンパイル時間 412 ms
コンパイル使用メモリ 11,252 KB
実行使用メモリ 15,448 KB
最終ジャッジ日時 2023-08-20 05:50:51
合計ジャッジ時間 7,906 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 80 ms
15,268 KB
testcase_01 AC 80 ms
15,244 KB
testcase_02 AC 126 ms
15,364 KB
testcase_03 AC 143 ms
15,448 KB
testcase_04 AC 158 ms
15,432 KB
testcase_05 AC 140 ms
15,240 KB
testcase_06 AC 128 ms
15,184 KB
testcase_07 AC 195 ms
15,276 KB
testcase_08 AC 140 ms
15,228 KB
testcase_09 AC 127 ms
15,396 KB
testcase_10 AC 130 ms
15,360 KB
testcase_11 AC 191 ms
15,216 KB
testcase_12 AC 175 ms
15,404 KB
testcase_13 AC 332 ms
15,228 KB
testcase_14 AC 176 ms
15,280 KB
testcase_15 AC 192 ms
15,256 KB
testcase_16 AC 178 ms
15,272 KB
testcase_17 AC 252 ms
15,288 KB
testcase_18 AC 177 ms
15,184 KB
testcase_19 AC 221 ms
15,408 KB
testcase_20 AC 176 ms
15,348 KB
testcase_21 AC 238 ms
15,224 KB
testcase_22 AC 187 ms
15,248 KB
testcase_23 AC 162 ms
15,368 KB
testcase_24 AC 331 ms
15,284 KB
testcase_25 AC 173 ms
15,252 KB
testcase_26 AC 207 ms
15,236 KB
testcase_27 AC 189 ms
15,280 KB
testcase_28 AC 167 ms
15,404 KB
testcase_29 AC 78 ms
15,116 KB
testcase_30 AC 78 ms
15,336 KB
testcase_31 AC 79 ms
15,056 KB
testcase_32 AC 82 ms
15,056 KB
testcase_33 AC 79 ms
15,308 KB
testcase_34 AC 81 ms
15,320 KB
testcase_35 AC 82 ms
15,280 KB
testcase_36 AC 80 ms
15,256 KB
testcase_37 AC 81 ms
15,320 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