Last active
November 19, 2015 02:07
Revisions
-
shoken0x revised this gist
Nov 19, 2015 . No changes.There are no files selected for viewing
-
shoken0x revised this gist
Nov 19, 2015 . 1 changed file with 2 additions and 0 deletions.There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -5,6 +5,8 @@ $C = [3, 2, 1, 3, 0, 2] $A = 620 #620円支払う # $A円を支払う最小の硬貨数を求める def slove ans = 0 5.downto(0) do |i| -
shoken0x created this gist
Nov 19, 2015 .There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,18 @@ #input $V = [1, 5, 10, 50, 100, 500] # 1円玉3枚, 10円玉2枚... 500円玉2枚 $C = [3, 2, 1, 3, 0, 2] $A = 620 #620円支払う def slove ans = 0 5.downto(0) do |i| t = [$A / $V[i], $C[i]].min $A -= t * $V[i] ans += t end puts ans end slove