C++ 代码
class Solution {
public:
int coinChange(vector<int>& coins, int amount) {
vector<int>f(amount+1,0x3f3f3f3f);
int i,j;
f[0]=0;
for(i=0;i<coins.size();i++)
for(j=coins[i];j<=amount;j++)
f[j]=min(f[j],f[j-coins[i]]+1);
retrun f[amount]!=0x3f3f3f3f?f[amount]:-1;
}
};