Sale Season Codechef Solution

Hello Programmers In this post, you will know how to solve the Sale Season Codechef Solution. The Problem Code is SALESEASON.

Sale Season Codechef Solution
Sale Season Codechef Solution

One more thing to add, don’t directly look for the solutions, first try to solve the problems of Codechef by yourself. If you find any difficulty after trying several times, then you can look for solutions.

Problem

It’s the sale season again and Chef bought items worth a total of X rupees. The sale season offer is as follows:

Find the final amount Chef needs to pay for his shopping.

Ezoicreport this adInput Format

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

Output Format

For each test case, output on a new line the final amount Chef needs to pay for his shopping.

Constraints

  • 1 ≤ T ≤ 100
    1 ≤ X ≤ 10000

Sample 1:

Input

4
15
70
250
1000

Output

15
70
225
975

Explanation:

Test case 11: Since X \le 100X≤100, there is no discount.

Test case 33: Here, X = 250X=250. Since 100 \lt 250 \le 1000100<250≤1000, discount is of 2525 rupees. Therefore, Chef needs to pay 250-25 = 225250−25=225 rupees.

Sale Season Codechef Solutions 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
	{
		Scanner sc = new Scanner(System.in);
		int T = sc.nextInt();
		for(int i=0; i<T; i++)
		{
		    int N = sc.nextInt();
		    double r = 0;
		    for(int j=0; j<N; j++)
		    {
		        int p = sc.nextInt();
		        int q = sc.nextInt();
		        int d = sc.nextInt();
		        double pp = p+((double)p*d)/100;
		        pp = pp-(pp*d)/100;
		        r=r+(p-pp)*q;
		    }
		    System.out.println(r);
		}
	}
}

Sale Season Codechef Solutions in CPP

 #include <iostream>
using namespace std;
int main() {
	int t;
	cin>>t;
	while(t--){
	    int n;
	    cin>>n;
	    double sum=0;
	    for(int i=1;i<=n;i++){
	        double p,x,d;
	        cin>>p>>x>>d;
	        double dis=double(d)/100;
	        double finalp=p+(p*dis);
	        double finalfp=finalp-(finalp*dis);
	        double loss=x*(p-finalfp);
	        sum+=loss;
	    }
	    cout<<fixed<<sum<<endl;
	}
	return 0;
}

Sale Season Codechef Solutions in Python

for testcases in range(int(input())):
    a=int(input())
    count=0
    for i in range(a):
        a,b,c=map(int,input().split())
        d=a*b
        a+=(0.01*c*a)
        a-=(0.01*a*c)
        a*=b
        count+=(d-a)
    print(float(count))
Ezoicreport this ad

Disclaimer: The above Problem (Sale Season ) is generated by CodeChef but the solution is provided by  BrokenProgrammers. This tutorial is only for Educational and Learning purpose.

Note:- I compile all programs, if there is any case program is not working and showing an error please let me know in the comment section. If you are using adblocker, please disable adblocker because some functions of the site may not work correctly.

Next: Car Trip Codechef Solution

Sharing Is Caring

Leave a Comment

Ezoicreport this ad