結果

問題 No.782 マイナス進数
ユーザー maimai
提出日時 2019-01-11 21:56:09
言語 Ruby
(3.3.0)
結果
AC  
実行時間 304 ms / 2,000 ms
コード長 309 bytes
コンパイル時間 96 ms
コンパイル使用メモリ 7,424 KB
実行使用メモリ 12,416 KB
最終ジャッジ日時 2024-05-07 13:13:07
合計ジャッジ時間 6,812 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 81 ms
11,904 KB
testcase_01 AC 76 ms
12,032 KB
testcase_02 AC 119 ms
12,288 KB
testcase_03 AC 134 ms
12,160 KB
testcase_04 AC 150 ms
12,160 KB
testcase_05 AC 131 ms
12,160 KB
testcase_06 AC 124 ms
12,160 KB
testcase_07 AC 190 ms
12,160 KB
testcase_08 AC 133 ms
12,288 KB
testcase_09 AC 127 ms
12,160 KB
testcase_10 AC 129 ms
12,288 KB
testcase_11 AC 176 ms
12,160 KB
testcase_12 AC 160 ms
12,416 KB
testcase_13 AC 304 ms
12,160 KB
testcase_14 AC 162 ms
12,160 KB
testcase_15 AC 179 ms
12,288 KB
testcase_16 AC 162 ms
12,288 KB
testcase_17 AC 235 ms
12,032 KB
testcase_18 AC 161 ms
12,288 KB
testcase_19 AC 200 ms
12,160 KB
testcase_20 AC 169 ms
12,160 KB
testcase_21 AC 224 ms
12,288 KB
testcase_22 AC 176 ms
12,288 KB
testcase_23 AC 154 ms
12,288 KB
testcase_24 AC 301 ms
12,288 KB
testcase_25 AC 167 ms
12,160 KB
testcase_26 AC 199 ms
12,288 KB
testcase_27 AC 183 ms
12,160 KB
testcase_28 AC 161 ms
12,160 KB
testcase_29 AC 80 ms
12,160 KB
testcase_30 AC 77 ms
12,032 KB
testcase_31 AC 76 ms
12,160 KB
testcase_32 AC 78 ms
12,032 KB
testcase_33 AC 75 ms
12,032 KB
testcase_34 AC 73 ms
12,160 KB
testcase_35 AC 74 ms
12,160 KB
testcase_36 AC 75 ms
12,160 KB
testcase_37 AC 75 ms
12,160 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