-
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