# Tech Tips

1. Uncategorized
2. 726 view

# Source Code

```package main

import (
"fmt"
"bufio"
"os"
"strconv"
"strings"
)

// Standard Input Function
func Scan() string {
reader := bufio.NewReader(os.Stdin)
input, _ := reader.ReadString('\n')
return strings.TrimRight(input, "\n")
}

// Min
func Min(v1, v2 int) int {
if v1 &amp;amp;gt; v2 { return v2
} else     { return v1 }
}

func Solve(amount int, values [6]int, limits []int) int {
answer := 0

for i := 5; i &amp;amp;gt;= 0; i-- {
num := Min(amount / values[i], limits[i])
amount -= num * values[i]
answer += num
}

return answer
}

func main() {
coinValue := [6]int{1, 5, 10, 50, 100, 500}
coinLimit := make([]int, 6)

fmt.Printf("Please input total amount to pay:")
amount,_ := strconv.Atoi(Scan())

for i := 0; i &amp;amp;lt; 6; i++ {
fmt.Printf("Please input limit number of %d yen:", coinValue[i])
coinLimit[i], _ = strconv.Atoi(Scan())
}

fmt.Printf("Answer : %d\n", Solve(amount, coinValue, coinLimit))
}
```

## Result

```Please input total amount to pay:620
Please input limit number of 1 yen:3
Please input limit number of 5 yen:2
Please input limit number of 10 yen:1
Please input limit number of 50 yen:3
Please input limit number of 100 yen:0
Please input limit number of 500 yen:2
Answer : 6
```