Physical Address

304 North Cardinal St.
Dorchester Center, MA 02124

The Rating Dilemma CodeChef Solution

Problem – The Rating Dilemma CodeChef Solution

Chef really likes to compete on Codechef, and he has gained an impressive rating of X, where X>0. There is also a parallel universe, where ratings on Codechef are negative instead. The only thing that remains unchanged in the parallel universe is Chef’s love for competing on Codechef. Chef’s rating on Codechef in the parallel universe is Y, where Y<0.

Due to some cosmic event, the parallel universe has been destroyed, resulting in Chef forgetting both X and Y. He only remembers the sum S=X+Y. He wonders what the maximum possible product of his ratings is, given that he knows the sum of his ratings.

Input Format

  • The first line of input will contain an integer T — the number of test cases. The description of T test cases follows.
  • The first and only line of each test case contains an integer S, the sum of Chef’s ratings.

Output Format

  • For each test case, output the maximum possible product of Chef’s ratings, given that he knows the sum of his ratings.


  • 1≤T≤10^3
  • 0≤S≤10^9


Subtask #1 (100 points): Original constraints

Sample 1:



Test case 1: We have X>0 and X+Y=0. This implies that Y=−X. The product of ratings is −X^2, and the maximum possible product is −1.

The Rating Dilemma CodeChef Solution in Java

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

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

/* 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 scan=new Scanner(;
		int t=scan.nextInt();
		while (t-->0){
		    int a=scan.nextInt();
		    //int b=scan.nextInt();

The Rating Dilemma CodeChef Solution in Pyth 3

# cook your dish here
for i in range(int(input())):

The Rating Dilemma CodeChef Solution in C++17

#include <iostream>
using namespace std;

int main() {
	// your code goes here
	int t,s;
	return 0;
The Rating Dilemma CodeChef Solution Review:

In our experience, we suggest you solve this The Rating Dilemma 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 The Rating Dilemma CodeChef Solution

Find on CodeChef


I hope this The Rating Dilemma 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 *