Coin Exchange Issues
Time limit:2000/1000 MS (java/others) Memory limit:65536/32768 K (java/others)
Total submission (s): 6538 accepted Submission (s): 3780
Problem Description
In a country there are only 1 cents, 2 cents, 3 cents, and there are many ways to exchange money n coins. Please write a procedure to figure out how many kinds of methods are in common.
Input
Only one positive integer per line n,n less than 32768.
Output
For each input, the output conversion method number.
Sample Input
2934
12553
Sample Output
718831
13137761
1, first determine the maximum value of 3 cents, and then find the value of each of the 3 cents coins can be taken by the maximum value, that is, the number of two-cent coins for the maximum of 2 cents plus one (two cents can take 0). The final value is added to the sum of all the two-cent coins at this time. (Conversion of the title to the total number of tokens based on the value of 3 cents)
2, the Internet to see someone else's code is said to be a complete backpack problem, well, now the level is not enough, still do not understand, interested students can see.
#include <iostream> #include <cstring> #include <math.h> #include <
Stdio.h> using namespace std;
int main () {int one,two,three;
int n,flag = 0;
while (~SCANF ("%d", &n)) {flag = 0;
three = N/3;
for (int i = 0; I <= three i++) {two = (N-(i * 3))/2;
Flag + = (two+1);
} if (N) cout << flag <<endl;
else cout << "0" << Endl;
return 0; }