Coin Exchange Question Hdu 1284__ACM

Source: Internet
Author: User
Tags time limit

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; }

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.