ICPC--1259:斐波那契数列&1260:硬币兑换

1259: Fibbonacci Number题目描述Your objective for this question is to develop a program which will generate a fibbonacci number. The fibbonacci function is defined as such: f(0) = 0 f(1) = 1 f(n) = f(n-1) + f(n-2)
Your program should be able to handle values of n in the range 0 to 50.
输入Each test case consists of one integer n in a single line where 0≤n≤50. The input is terminated by -1.
输出Print out the answer in a single line for each test case.
样例输入【ICPC--1259:斐波那契数列&1260:硬币兑换】345-1样例输出235代码#includeusing namespace std;int main(){long long n;long long a[52];a[0]=0;a[1]=1;for(int i=2;i<51;i++){a[i]=a[i-1]+a[i-2];}while(scanf("%lld",}return 0;}1260: 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, or two 5-cent coins and one 1-cent coin, or 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 100 cents.
输入The input file contains any number of lines, each one consisting of a number ( ≤250 ) for the amount of money in cents.
输出For each input line, output a line containing the number of different ways of making changes with the above 5 types of coins.
样例输入1126样例输出413代码#includeusing namespace std;int main(){int n;while(~scanf("%d",a=n/50;b=n/25;c=n/10;d=n/5;e=n;for(int i=0;i<=a;i++){for(int j=0;j<=b;j++){for(int p=0;p<=c;p++ ){for(int q=0;q<=d;q++){for(int t=0;t<=e;t++){if(50*i+j*25+p*10+q*5+t==n}}}}}}printf("%d\n",sum);sum=0;}return 0;}