Smallest Numbers of Notes | Codechef solution
Problem of Smallest Numbers of Notes | Codechef solution:-
Consider a currency system in which there are notes of six denominations, namely, Rs. 1, Rs. 2, Rs. 5, Rs. 10, Rs. 50, Rs. 100.
If the sum of Rs. N is input, write a program to computer smallest number of notes that will combine to give Rs. N.
Input of Smallest Numbers of Notes | Codechef solution
The first line contains an integer T, total number of testcases. Then follow T lines, each line contains an integer N.
Output
For each test case, display the smallest number of notes that will combine to give N, in a new line.
Constraints
- 1 ≤ T ≤ 1000
- 1 ≤ N ≤ 1000000
Example
Input
3
1200
500
242
Output
12
5
7
Code:-
#include <iostream> using namespace std; int main() { int t,n; cin>>t; while(t--) { cin>>n; int r=0,r1,a; if(n>=100) { r=r+n/100; a=r*100; n=n-a; } if(n>=50) { r1=n/50; r=r+r1; a=r1*50; n=n-a; } if(n>=10) { r1=n/10; r=r+r1; a=r1*10; n=n-a; } if(n>=5) { r1=n/5; r=r+r1; a=r1*5; n=n-a; } if(n>=2) { r1=n/2; r=r+r1; a=r1*2; n=n-a; } if(n>=1) { r1=n/1; r=r+r1; a=r1*1; n=n-a; } cout<<r<<endl; } return 0; }
Recommended Post:
-
codechef problems:-
Wipro :-
- Update the booking ID | Wipro previous year question paper solution
- Pages in PDF
- Find the location id
- Find the odd digits
- Find the Product ID
Infytq :-
Key Points;-
Hackerrank:-
- Python : missing characters : hackerrank solution
- Python : string transformation | Hackerrank solution
- Active Traders certification test problem | Hackerrank Solution
- Usernames changes certification test problem | Hackerrank Solution
- string Representation of objects certification test hackerrank solution
- Average Function | hackerrank certification problem solution
C-tutorial:-
- Micros in C
- Pointer in c
- Function declaration
- Types of user define function
- return type of function
- 2D array
See more:-
- c program to convert specified days into years weeks and days
- Print Reverse Hollow Pyramid
- Update the booking ID | Wipro previous year question paper
- Pages in PDF | Wipro previous year question paper
- Sparse Matrix in data structure
- Find the location ID | Wipro previous year Coding question
- find the odd digits | Wipro Coding question
- Find the product id | Wipro Coding question
- Difference between static and dynamic memory allocation
- What is asymptotic Notation