結果

問題 No.757 チャンパーノウン定数 (2)
ユーザー maimai
提出日時 2018-12-05 10:50:56
言語 Ruby
(3.3.0)
結果
RE  
実行時間 -
コード長 583 bytes
コンパイル時間 258 ms
コンパイル使用メモリ 11,528 KB
実行使用メモリ 367,512 KB
最終ジャッジ日時 2023-09-25 13:22:50
合計ジャッジ時間 10,818 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 81 ms
15,320 KB
testcase_01 AC 81 ms
15,124 KB
testcase_02 AC 80 ms
15,056 KB
testcase_03 AC 83 ms
15,324 KB
testcase_04 AC 79 ms
15,156 KB
testcase_05 AC 79 ms
15,244 KB
testcase_06 AC 80 ms
15,248 KB
testcase_07 AC 78 ms
15,068 KB
testcase_08 AC 80 ms
15,096 KB
testcase_09 AC 82 ms
15,080 KB
testcase_10 AC 83 ms
15,056 KB
testcase_11 AC 80 ms
15,068 KB
testcase_12 AC 78 ms
15,160 KB
testcase_13 AC 80 ms
15,292 KB
testcase_14 AC 79 ms
15,128 KB
testcase_15 AC 79 ms
15,116 KB
testcase_16 AC 79 ms
15,108 KB
testcase_17 AC 79 ms
15,276 KB
testcase_18 AC 78 ms
15,280 KB
testcase_19 AC 78 ms
15,340 KB
testcase_20 AC 82 ms
15,024 KB
testcase_21 AC 80 ms
15,072 KB
testcase_22 AC 80 ms
15,044 KB
testcase_23 AC 80 ms
15,100 KB
testcase_24 AC 78 ms
15,056 KB
testcase_25 AC 81 ms
15,312 KB
testcase_26 AC 80 ms
15,240 KB
testcase_27 AC 79 ms
15,152 KB
testcase_28 RE -
testcase_29 RE -
testcase_30 AC 101 ms
31,320 KB
testcase_31 RE -
testcase_32 AC 80 ms
15,700 KB
testcase_33 RE -
testcase_34 RE -
testcase_35 RE -
testcase_36 AC 114 ms
41,720 KB
testcase_37 RE -
testcase_38 RE -
testcase_39 RE -
testcase_40 RE -
testcase_41 RE -
testcase_42 RE -
testcase_43 RE -
testcase_44 RE -
testcase_45 RE -
testcase_46 RE -
testcase_47 RE -
testcase_48 RE -
testcase_49 RE -
testcase_50 AC 80 ms
15,060 KB
testcase_51 AC 80 ms
15,016 KB
testcase_52 AC 79 ms
15,160 KB
testcase_53 AC 79 ms
15,280 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

B = gets.to_i
N = gets.to_i(B)


# guchoku
# str = ((0..999).map{|e|e.to_s(B)}*"")
# puts str[0..50]
# puts str[N]


def dig(y, sz, ofs, w)
    # range "000".."999"
    i = y/w
    d = y%w
    i.to_s(B)[d] || "0"
end

def climb(x, sz, ofs, w)
    # range "100".."999"
    len = (sz-ofs)*w
    # p [x,sz,ofs,w]
    # p (ofs...sz).map{|e|e.to_s(B)}
    if x >= len
        climb(x-len, sz*B, sz, w+1)
    else
        # p B**(w-1)
        # ((ofs...sz).map{|e|e.to_s(B)}*"")[x]
        dig(x+B**(w-1)*w, sz, ofs, w)
    end
end


if N == 0
    p 0
else
    puts climb(N-1, B, 1, 1)
end
0