GAMES - How Many Games?
Problem Statement:
A player has played unknown number of games. We know the average score of the player (sum of scores in all the games / no. of games). Find the minimum number of games the player should have played to achieve that average.
The player can score any non-negative integer score in a game.
Input:
The first line consists of an integer t, the number of test cases. Each test case consists of a single Rational Number which represents the average score of the player.
Output:
For each test case, find the minimum number of matches the player should have played to achieve that average.
Input Constraints:
1 <= t <= 1000
1 <= avg <= 1000000 (maximum 4 digits after the decimal place)
Example:
Sample Input: 3 5 5.5 30.25 Sample Output: 1 2 4
hide comments
|
the_vr7:
2020-12-05 06:15:21
I solved this question by using Linear Search but is there any other method or trick to solve this question and reduce the time complexity
|
|
gokulan_cv:
2020-07-06 08:47:09
Ignore People Who are saying AC in 1st go 2nd Go. Comment section is to provide hint for those trying to solve not to show off. Grow Up!!!! |
|
gokulan_cv:
2020-07-06 08:46:20
HINT: Convert To Round Numbers W/o Decimals. Think, what will you do to convert. Math operators then Think Similar Approach! |
|
sinu93065:
2020-06-01 09:50:32
can anyone give me a solution by using Double instead of using string... |
|
fighter_4:
2020-04-09 13:58:39
guys, I do not why but take input as a string, it works, whereas a double will not!! |
|
fighter_4:
2020-04-09 13:00:34
@aspro life saviour bro!!!
|
|
rising_stark:
2019-12-16 15:10:28
There is no thought of recurring. The answer to 0.3333 will be 10000 not 3 (using 4/3 as solution) Last edit: 2019-12-16 15:55:52 |
|
cjchirag7:
2019-12-13 14:28:58
Try using long double instead of double to pass all the testcases |
|
kishorerabha:
2019-10-31 15:16:40
why doesn't using double work? are the values being provided have decimal places more than 15? |
|
pratiyush_05:
2019-06-02 16:42:36
Was not working with double so I tried with string and BAAM ,....got accepted |
Added by: | cegprakash |
Date: | 2012-10-12 |
Time limit: | 1s |
Source limit: | 50000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Languages: | All except: ASM64 |