[Solution] The Rating Dilemma solution codechef

The Rating Dilemma solution codechef – Chef really likes to compete on Codechef, and he has gained an impressive rating of XX, where X>0X>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 YY, where Y<0Y<0.

The Rating Dilemma solution codechef

Due to some cosmic event, the parallel universe has been destroyed, resulting in Chef forgetting both XX and YY. He only remembers the sum S=X+YS=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 TT — the number of test cases. The description of TT test cases follows.
  • The first and only line of each test case contains an integer SS, 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.

Constraints

  • 1T1031≤T≤103
  • 0S1090≤S≤109

The Rating Dilemma solution codechef

Subtask #1 (100 points): Original constraints

Sample Input 1 

2
0
1

Sample Output 1 

-1
-2

The Rating Dilemma solution codechef

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

For Solution

Click Here

Leave a Comment