Nine degrees oj-topic 1549: Currency issues

Source: Internet
Author: User

Title Description:

It is known to have a face value of $1, $2, $5, $10, $20, $50, a currency of $100 (which can be considered infinitely many), an item with a price of x and needs to be paid exactly, i.e. no change is generated.
At least a few currencies are required to complete the payment.
For example, if a price of $12 is paid, a minimum of $10 and a $2 will be required to complete the payment in two currencies.

Input:

The input contains multiple sets of test data, each set containing only one integer p (1<=p<=100000000), which is the price of the item to be paid.

Output:

For each set of input data, the output is only an integer representing the minimum number of currency sheets required.

Sample input:
101113
Sample output:
123
Source:
2014 Wang Forum Postgraduate Pilot Practice Competition (ii)


#include <stdio.h> int main () {    int x,a,b,c,d,e,f,g;    while (scanf ("%d", &x)!=eof)    {        a=b=c=d=e=f=g=0;                 a=x/100;        x-=a*100;        B=X/50;        x-=b*50;        C=X/20;        x-=c*20;        D=X/10;        x-=d*10;        E=X/5;        x-=e*5;        F=X/2;        x-=f*2;        G=X/1;        x-=g*1;             printf ("%d\n", a+b+c+d+e+f+g);    }      return 0;} /**************************************************************    problem:1549    user:vhreal    Language:c    result:accepted    time:10 ms    memory:912 kb********************************************** ******************/


Nine degrees oj-topic 1549: Currency issues

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.