結果

問題 No.319 happy b1rthday 2 me
ユーザー 小指が強い人小指が強い人
提出日時 2015-12-12 17:42:58
言語 Ruby
(3.3.0)
結果
WA  
実行時間 -
コード長 2,346 bytes
コンパイル時間 205 ms
コンパイル使用メモリ 11,584 KB
実行使用メモリ 15,324 KB
最終ジャッジ日時 2023-10-13 11:50:34
合計ジャッジ時間 4,991 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 83 ms
15,136 KB
testcase_01 AC 89 ms
15,120 KB
testcase_02 AC 88 ms
15,080 KB
testcase_03 AC 89 ms
15,160 KB
testcase_04 AC 84 ms
15,308 KB
testcase_05 AC 83 ms
15,308 KB
testcase_06 AC 83 ms
15,080 KB
testcase_07 AC 82 ms
15,228 KB
testcase_08 AC 83 ms
15,140 KB
testcase_09 AC 82 ms
15,172 KB
testcase_10 AC 82 ms
15,268 KB
testcase_11 AC 82 ms
15,072 KB
testcase_12 AC 82 ms
15,284 KB
testcase_13 AC 82 ms
15,160 KB
testcase_14 AC 82 ms
15,076 KB
testcase_15 WA -
testcase_16 AC 83 ms
15,280 KB
testcase_17 AC 82 ms
15,264 KB
testcase_18 AC 87 ms
15,160 KB
testcase_19 AC 84 ms
15,324 KB
testcase_20 AC 89 ms
15,144 KB
testcase_21 AC 88 ms
15,280 KB
testcase_22 AC 87 ms
15,116 KB
testcase_23 AC 87 ms
15,036 KB
testcase_24 AC 86 ms
15,284 KB
testcase_25 AC 84 ms
15,144 KB
testcase_26 AC 81 ms
15,020 KB
testcase_27 AC 82 ms
15,256 KB
testcase_28 AC 82 ms
15,120 KB
testcase_29 AC 80 ms
15,092 KB
testcase_30 AC 85 ms
15,156 KB
testcase_31 AC 81 ms
15,132 KB
testcase_32 AC 82 ms
15,028 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.rb:15: warning: assigned but unused variable - an
Main.rb:15: warning: assigned but unused variable - bn
Main.rb:19: warning: assigned but unused variable - ch
Main.rb:20: warning: assigned but unused variable - ss
Syntax OK

ソースコード

diff #

#happy b1rthday 2 me
def comb(n, m)
    q = 1
    m.times do |x|
        q *= n - x
        q /= (x + 1)
    end
    return q
end
a, b = gets.split
if a == b
    puts 0
    exit
end
an, bn = a.to_i, b.to_i
la = a.length
lb = b.length
res = 0
ch = 0
ss = ""
=begin
(a.to_i).upto(b.to_i) do |x|
    ss += x.to_s
end
(ss.length - 1).times do |i|
    ch += 1 if ss[i, 2].to_i == 12
end
puts ch
=end
la.upto(lb) do |x|
    if x == 1
        res += 1
        next
    end
    d = x - 2
    res += 10 ** d
    res += d * 9 * 10 ** (d - 1) if d > 0
    if x >= 3
        res += 10 ** (x - 2)
    else
        res += 1
    end
end
y = 2
(la - y).downto(0) do |i|
    j = la - i - y
    q = 0
    mid = a[i, y].to_i
    left = a[0, i].to_i
    right = a[i + y, j].to_i
    if i == 0
        if mid > 12
            q += 10 ** j
        elsif mid == 12
            q += right
        end
    elsif i == la - y
        q += left - 10 ** (i - 1)
        q += 1 if mid > 12
    else
        if mid > 12
            q += (left - 10 ** (i - 1) + 1) * 10 ** j
        elsif mid < 12
            q += (left - 10 ** (i - 1)) * 10 ** j
        else
            q += (left - 10 ** (i - 1)) * 10 ** j
            q += right
        end
    end
    res -= q
end
if a.length - 2 >= 0
    if a[0].to_i > 2
        res -= 10 ** (a.length - 2)
    elsif a[0].to_i == 2
        res -= a[1, a.length - 2].to_i + 1
        res += 1 if a[a.length - 1].to_i < 2
    end
else
    if a[0].to_i >= 2
        res -= 1
    end
end
(lb - y).downto(0) do |i|
    j = lb - i - y
    q = 0
    mid = b[i, y].to_i
    left = b[0, i].to_i
    right = b[i + y, j].to_i
    if i == 0
        if mid < 12
            q += 10 ** j
        elsif mid == 12
            q += 10 ** j - right - 1
        end
    elsif i == lb - y
        q += 10 ** i - left
        q -= 1 if mid >= 12
    else
        if mid < 12
            q += (10 ** i - left) * 10 ** j
        elsif mid > 12
            q += (10 ** i - left - 1) * 10 ** j
        else
            q += (10 ** i - left - 1) * 10 ** j
            q += 10 ** j - right - 1
        end
    end
    res -= q
end
if b.length - 2 >= 0
    if b[0].to_i < 2
        res -= 10 ** (b.length - 2)
    elsif b[0].to_i == 2
        res -= 10 ** (b.length - 2) - b[1, b.length - 2].to_i
        res += 1 if b[b.length - 1].to_i >= 2
    end
end
puts res
0