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 / 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.
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 <= avg <= 1000000 (maximum 4 digits after the decimal place)
Sample Input: 3 5 5.5 30.25 Sample Output: 1 2 4
Dont use double use string for input ;even though ur answer is correct using double.
got AC in one go in 0 sec..
basic maths..just handling double is tricky....got ac using [spoiler]Last edit: 2017-08-02 12:58:20
The question is pretty easy and I got the idea at first instance, but, implementation was wrong many times, because of the way I was reading input. Also, got a few TLE - in which I learned the cost of having multiple "if" conditions.
why to take input as string instead of double??
this is easy!!
Take input as a string. Remember how floating points are stored. :)
finally happy to remove it from my todo list after a long time though lots of WAs for this ques :-))
Can someone plz explain what may be the possible reason to get WA.I am getting correct answer for every test cases even in ideone but here it is still showing WA.Last edit: 2016-09-25 08:09:23