Minimum Coins CodeChef Solution

Problem – Minimum Coins CodeChef Solution

There are only 2 type of denominations in Chefland:

  • Coins worth 1 rupee each
  • Notes worth 10 rupees each

Chef wants to pay his friend exactly X rupees. What is the minimum number of coins Chef needs to pay exactly X rupees?

Input Format

  • The first line of input will contain a single integer T, denoting the number of test cases.
  • Each test case consists of a single line of input containing a single integer X.

Output Format

For each test case, output on a new line the minimum number of coins Chef needs to pay exactly X rupees.

Constraints

  • 1≤T≤1000
  • 1≤X≤1000

Sample 1:

Input: 4
53
100
9
11
Output: 3
0
9
1

Explanation:

Test case 1: Chef can use 5 notes and 3 coins in the optimal case.

Test case 2: Chef can use 10 notes and 0 coins in the optimal case.

Test case 3: Chef can only use 9 coins.

Test case 4: Chef can use 1 note and 1 coin in the optimal case.

Minimum Coins CodeChef Solution in C++17

#include <iostream>
using namespace std;

int main() {
	int t,x;
	cin>>t;
	while(t--){
	    cin>>x;
	    if(x<10)
	    cout<<x<<endl;
	    else
	    cout<<x%10<<endl;
	}
	return 0;
}

Minimum Coins CodeChef Solution in Pyth 3

t = int(input())
for _ in range(t):
    a = int(input())
    print(a%10)

Minimum Coins CodeChef Solution in Java

import java.util.*;
import java.lang.*;
import java.io.*;

class Codechef
{
	public static void main (String[] args) throws java.lang.Exception
	{
	Scanner s=new Scanner(System.in);
    int T=s.nextInt();
    while(T-->0)
      {
        int x=s.nextInt();
        System.out.println(x%10); 
      }
	}
}
Minimum Coins CodeChef Solution Review:

In our experience, we suggest you solve this Minimum Coins CodeChef Solution and gain some new skills from Professionals completely free and we assure you will be worth it.

If you are stuck anywhere between any coding problem, just visit Queslers to get the Minimum Coins CodeChef Solution

Find on CodeChef

Conclusion:

I hope this Minimum Coins CodeChef Solution would be useful for you to learn something new from this problem. If it helped you then don’t forget to bookmark our site for more Coding Solutions.

This Problem is intended for audiences of all experiences who are interested in learning about Data Science in a business context; there are no prerequisites.

Keep Learning!

More Coding Solutions >>

LeetCode Solutions

Hacker Rank Solutions

CodeChef Solutions

Leave a Reply

Your email address will not be published. Required fields are marked *