Best Coupon CodeChef Solution

Problem – Best Coupon CodeChef Solution

Chef is ordering food online (instead of cooking) and the bill comes out to be Rs. XX. Chef can use one of the following two coupons to avail a discount.

  • Get 1010 percent off on the bill amount
  • Get a flat discount of Rs. 100100 on the bill amount

What is the maximum discount Chef can avail?

Input Format

  • The first line contains a single integer TT – the number of test cases. Then the test cases follow.
  • The first and only line of each test case contains a single integer XX – the bill amount before discount.

Output Format

For each testcase, output the maximum discount Chef can avail.

Constraints

  • 1 \leq T \leq 1001≤T≤100
  • 100 \leq X \leq 10000100≤X≤10000
  • XX is a multiple of 100100.

Sample 1:

Input: 3
300
1300
1000
Output: 100
130
100

Explanation:

Test case 1: Using the second coupon, Chef can get a flat discount of Rs. 100100, which is maximum.

Test case 2: Using the first coupon, Chef can get a 1010 percent discount of Rs. 130130, which is maximum.

Test case 3: No matter which coupon Chef chooses Chef will get a discount of Rs. 100100.

Best Coupon CodeChef Solution in Java

/* package codechef; // don't place package name! */

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

/* Name of the class has to be "Main" only if the class is public. */
class Codechef
{
	public static void main (String[] args) throws java.lang.Exception
	{
		// your code goes here
		Scanner sc=new Scanner (System.in);
		int t=sc.nextInt();
		while(t-->0){
		    int x=sc.nextInt();
		    int y=x/10;
		    if(y>100){
		        System.out.println(y);
		    }
		    else{
		        System.out.println("100");
		    }
		}
	}
}

Best Coupon CodeChef Solution in Pyth 3

# cook your dish here
for i in range(int(input())):
    a=int(input())
    print(max((int(a*0.1)),100))

Best Coupon CodeChef Solution in C++17

#include <iostream>
using namespace std;

int main() {
	int t;
	cin>>t;
	while(t--){
	    int a;
	    cin>>a;
	    if(a<1000){
	        cout<<"100"<<endl;
	    }
	    else{
	        cout<<a/10<<endl;
	    }
	}
	return 0;
}
Best Coupon CodeChef Solution Review:

In our experience, we suggest you solve this Best Coupon 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 Best Coupon CodeChef Solution

Find on CodeChef

Conclusion:

I hope this Best Coupon 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.