Skip to content

Instantly share code, notes, and snippets.

@hamuhei1412
Last active March 21, 2018 14:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hamuhei1412/20ab840abe3cf7827adadd928e37da1a to your computer and use it in GitHub Desktop.
Save hamuhei1412/20ab840abe3cf7827adadd928e37da1a to your computer and use it in GitHub Desktop.
ABC087B
A = gets.to_i
B = gets.to_i
C = gets.to_i
X = gets.to_i
#ここまで入力
ans = 0
a = 0 #500円玉の枚数
while a != A+1 do
b = 0 #100円玉の枚数
while b != B+1 do
c = 0 #50円玉の枚数
while c != C+1 do
if((a*500+b*100+c*50)==X) #合計金額がXと合致したらansを1増やす
ans += 1
end
c += 1
end
b += 1
end
a += 1
end
puts ans
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment