結果

問題 No.782 マイナス進数
ユーザー maimai
提出日時 2019-01-11 21:54:14
言語 Ruby
(3.2.2)
結果
WA  
実行時間 -
コード長 286 bytes
コンパイル時間 308 ms
コンパイル使用メモリ 11,528 KB
実行使用メモリ 15,436 KB
最終ジャッジ日時 2023-08-20 05:46:37
合計ジャッジ時間 7,939 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 79 ms
15,232 KB
testcase_01 AC 79 ms
15,120 KB
testcase_02 AC 133 ms
15,224 KB
testcase_03 AC 143 ms
15,168 KB
testcase_04 AC 156 ms
15,300 KB
testcase_05 AC 135 ms
15,180 KB
testcase_06 AC 129 ms
15,232 KB
testcase_07 AC 198 ms
15,016 KB
testcase_08 AC 141 ms
15,376 KB
testcase_09 AC 130 ms
15,376 KB
testcase_10 AC 126 ms
15,420 KB
testcase_11 AC 190 ms
15,212 KB
testcase_12 AC 175 ms
15,276 KB
testcase_13 AC 332 ms
15,384 KB
testcase_14 AC 172 ms
15,388 KB
testcase_15 AC 192 ms
15,304 KB
testcase_16 AC 175 ms
15,388 KB
testcase_17 AC 260 ms
15,236 KB
testcase_18 AC 175 ms
15,124 KB
testcase_19 AC 227 ms
15,176 KB
testcase_20 AC 175 ms
15,264 KB
testcase_21 AC 240 ms
15,436 KB
testcase_22 AC 189 ms
15,324 KB
testcase_23 AC 159 ms
15,224 KB
testcase_24 AC 320 ms
15,172 KB
testcase_25 AC 176 ms
15,404 KB
testcase_26 AC 213 ms
15,312 KB
testcase_27 AC 189 ms
15,236 KB
testcase_28 AC 171 ms
15,132 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
        exit if i > 100
    end
    
    puts l.reverse
end
0