Skip to content

Instantly share code, notes, and snippets.

@hamuhei1412
Last active March 21, 2018 14:54
Show Gist options
  • Save hamuhei1412/f4290e9176d13e2ad23cd9e49bb70bb5 to your computer and use it in GitHub Desktop.
Save hamuhei1412/f4290e9176d13e2ad23cd9e49bb70bb5 to your computer and use it in GitHub Desktop.
ABC083B
N,A,B = gets.split.map(&:to_i) #N,A,Bを取得
ans = 0
def calu(n) #各桁の和を計算する関数を宣言
a = n #rubyの関数の仕様を把握してないので一応
@i = 0 #各桁の和を代入する変数
while a >= 10 #各桁の和を求める
@i += a%10
a /= 10
end
@i += a%10 #1桁の数を拾うために
@i
end
w = 1
while w != N+1
if calu(w) >= A&&calu(w) <= B #各桁の和がA以上B以下の数のみ
ans += w
end
w += 1
end
puts ans
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment