問題
https://atcoder.jp/contests/abs/tasks/abc083_b
1回目
回答
N,A,B = gets.chomp.split(" ").map(&:to_i)
res = 0
for num in 1..N do
numList = num.to_s.chars.map(&:to_i)
sum = 0
for n in numList do
sum += n
end
if sum >= A && sum <= B
res += num
end
end
puts res
結果
2回目
回答
N,A,B = gets.chomp.split(" ").map(&:to_i)
res = 0
for num in 1..N do
s = 0
n = num
while n > 0 do
s += n % 10
n /= 10
end
if s >= A && s <= B
res += num
end
end
puts res