T 103 - Negative Marking

1.7k views Asked by At

Raju is giving his JEE Main exam. The exam has Q questions and Raju needs S marks to pass. Giving the correct answer to a question awards the student with 4 marks whereas giving the incorrect answer to a question awards the student with negative 3 (-3) marks. If a student chooses to not answer a question at all, he is awarded 0 marks.

Write a program to calculate the minimum accuracy that Raju will need in order to pass the exam.

Input Input consists of multiple test cases. Each test case consists of two integers Q and S

Output Print the minimum accuracy upto 2 decimal places Print -1 if it is impossible to pass the exam

Sample Input 0

2

10 40

10 33

Sample Output 0

100.00

90.00

1

There are 1 answers

0
Suyash Krishna On

Think of this as a simultaneous equation problem.

4x - 3y = S
 x +  y = Q

For the second scenario, your equations will be :

4x - 3y = 33
 x +  y = 10

After solving 'x' will be equal to the minimum number of questions he has to solve correctly. Calculate what percentage of 'Q' is 'x'.

That's the concept, think how you would approach it programatically :)