### 算法：货币兑换问题

f(0,n) = 1 对于任意的n >=0

f(x,1) = 1 对于任意的x >=0。

f(14,5)=f(14,2)+f(9,2)+f(4,2) = 8 + 5 + 3= 16。

UVA上有两道类似的题：

## 674 - Coin Change

Suppose there are 5 types of coins: 50-cent, 25-cent, 10-cent, 5-cent, and 1-cent. We want to make changes with these coins for a given amount of money.

For example, if we have 11 cents, then we can make changes with one 10-cent coin and one 1-cent coin, two 5-cent coins and one 1-cent coin, one 5-cent coin and six 1-cent coins, or eleven 1-cent coins. So there are four ways of making changes for 11 cents with the above coins. Note that we count that there is one way of making change for zero cent.

Write a program to find the total number of different ways of making changes for any amount of money in cents. Your program should be able to handle up to 7489 cents.

### Input

The input file contains any number of lines, each one consisting of a number for the amount of money in cents.

### Output

For each input line, output a line containing the number of different ways of making changes with the above 5 types of coins.

11
26

4
13

## 147 - Dollars

0.20
2.00
0.00

0.20 4
2.00 293

147这道题的代码如下：

in = fopen("input.txt", "r");
if (!in) return -1;

const uint32_t maxvalue=30000/5 + 1;
uint64_t* v1=new uint64_t[maxvalue];
const uint32_t coins[]={4,10,20,40,100,200,400,1000,2000};
const uint32_t coinsLen=sizeof(coins)/sizeof(coins[0]);
//compute for 10c;
for(uint32_t i=0;i!=maxvalue;++i){
v1[i]=i/2 +1;
//v1[i]=1;
}

for(uint32_t j=0;j!=coinsLen;++j){
uint32_t c=coins[j];
for(uint32_t i=0;i!=maxvalue;++i){
if(i>=c) v1[i]+=v1[i-c];
}
}

int c;
while(true){
int num = 0;
while((c=getc_unlocked(in))!=EOF){
if (isspace(c)) {
break;
} else if(c=='.'){
continue;
} else if(c>='0' && c<='9'){
num = num * 10 + c - '0';
} else
throw std::runtime_error("error input");
}
if(num==0) break;

std::cout<<std::setiosflags(std::ios::fixed)
<<std::setprecision(2)<<std::setw(6)<<num/(double)100
<<std::setw(17)<<v1[num/5]<<"\n";
}

fclose(in);