結果

問題 No.782 マイナス進数
ユーザー maimai
提出日時 2019-01-11 21:54:48
言語 Ruby
(3.3.0)
結果
WA  
実行時間 -
コード長 262 bytes
コンパイル時間 150 ms
コンパイル使用メモリ 11,236 KB
実行使用メモリ 15,476 KB
最終ジャッジ日時 2023-08-20 05:47:12
合計ジャッジ時間 7,610 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 77 ms
15,264 KB
testcase_01 AC 78 ms
15,168 KB
testcase_02 AC 126 ms
15,172 KB
testcase_03 AC 144 ms
15,124 KB
testcase_04 AC 156 ms
15,268 KB
testcase_05 AC 133 ms
15,212 KB
testcase_06 AC 126 ms
15,132 KB
testcase_07 AC 191 ms
15,388 KB
testcase_08 AC 139 ms
15,244 KB
testcase_09 AC 125 ms
15,264 KB
testcase_10 AC 126 ms
15,216 KB
testcase_11 AC 188 ms
15,384 KB
testcase_12 AC 174 ms
15,212 KB
testcase_13 AC 329 ms
15,476 KB
testcase_14 AC 174 ms
15,244 KB
testcase_15 AC 190 ms
15,168 KB
testcase_16 AC 175 ms
15,172 KB
testcase_17 AC 249 ms
15,160 KB
testcase_18 AC 175 ms
15,428 KB
testcase_19 AC 223 ms
15,240 KB
testcase_20 AC 176 ms
15,264 KB
testcase_21 AC 242 ms
15,192 KB
testcase_22 AC 185 ms
15,264 KB
testcase_23 AC 161 ms
15,252 KB
testcase_24 AC 329 ms
15,256 KB
testcase_25 AC 175 ms
15,384 KB
testcase_26 AC 207 ms
15,212 KB
testcase_27 AC 190 ms
15,420 KB
testcase_28 AC 170 ms
15,236 KB
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.rb:11: 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
    
    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