Instagram
youtube
Facebook
Twitter

Python Minimum Coins program Codechef solution

           Python Minimum Coins program Codechef solution

Problem

There are only two types of denominations in Chefland:

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

The 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 Input:

53 

100 

11

Sample Output:

1

Explanation:

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

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

Test case 3: The chef can only use nine coins.

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

Solution:

n=int(input(“Enter the number of terms: “))

for i in range(n):

    x=int(input(“Enter the amount: “))

    c=x%10

    print(c)

           Steps to solve this problem:

  1. Ask the user to enter the number of the terms.
  2. In the loop, ask the user to enter the amount.
  3. Calculate the remainder using the modulus operator and store it in c.
  4. Print the value of c.