GAMES - How Many Games?
A player has played unknown number of games. We know the average score of the player (sum of scores in all the games / number 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.
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.
For each test case, find the minimum number of matches the player should have played to achieve that average.
1 <= t <= 1000
1 <= average <= 1000000 (maximum 4 digits after the decimal place)
Input: 3 5 5.5 30.25 Output: 1 2 4
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
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!!!!
HINT: Convert To Round Numbers W/o Decimals. Think, what will you do to convert. Math operators then Think Similar Approach!
can anyone give me a solution by using Double instead of using string...
guys, I do not why but take input as a string, it works, whereas a double will not!!
@aspro life saviour bro!!!
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
Try using long double instead of double to pass all the testcases
why doesn't using double work? are the values being provided have decimal places more than 15?
|Cluster:||Cube (Intel G860)|
|Languages:||All except: ASM64|