9-degree OJ-question 1549: currency problem, 9-degree oj1549 currency

Source: Internet
Author: User

9-degree OJ-question 1549: currency problem, 9-degree oj1549 currency

Description:

It is known that the nominal value is 1 yuan, 2 yuan, 5 yuan, 10 yuan, 20 yuan, 50 yuan, a number of currencies of 100 yuan (can be considered infinite ), you need to pay for an item whose price is x, and pay exactly for it.
Please, at least a few currencies are required to complete the payment.
For example, if the payment price is 12 yuan, you need at least 10 yuan and 2 yuan, that is, you can complete the payment in two currencies.

Input:

Input contains multiple groups of test data, each group contains only one integer p (1 <= p <= 100000000), for the price of the item to be paid.

Output:

For each group of input data, only one integer is output, representing the minimum number of required currencies.

Sample input:
101113
Sample output:
123
Source:
2014 Wang Dao Forum study life trial exercise (2)


#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****************************************************************/


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.