有不限量的1 0元 5 元 1元若干個,今有一個零錢要找開 有幾種找法。ex 15 元可以找成(0 0 15)(0 1 10)(0 2 5)(0 3 0)(1 0 5)(1 1 0)) 6種找法
public class HW01 {public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int money = sc.nextInt();
int count = 0 ;
for (int i = 0 ; i <= money/10 ; i++)
for (int j = 0 ; j<=money /5 ;j++)
for (int k = 0 ; k<=money ; k++ )
{
if(i*10+j*5+k == money)
{
count ++;
System.out.printf("(%d %d %d)",i,j,k);
}}
System.out.printf("%d",count);
}}