GAMES - HOW MANY GAMES

no tags 

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
sinersnvrsleep: 2018-02-06 12:16:11

dont give up on this question very easy start with the very basic of numerator and denominators

bks19: 2017-07-05 05:27:50

Dont use double use string for input ;even though ur answer is correct using double.

sanjitpd_777: 2017-06-23 10:19:22

got AC in one go in 0 sec..
Store number in string than extract decimal number from it.
Just CHECK how you can [spoiler]

Last edit: 2017-08-02 12:58:01
starbot: 2017-06-14 16:13:01

basic maths..just handling double is tricky....got ac using [spoiler]

Last edit: 2017-08-02 12:58:20
prabodh prakash: 2017-05-15 17:30:29

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.

nilabja16180: 2017-03-23 09:49:08

Good problem!

simran07: 2017-03-07 19:00:32

why to take input as string instead of double??

reply : Because strings are precise. You need to learn how float/double works

Last edit: 2017-03-08 09:14:29
ranjita: 2017-01-29 15:22:15

this is easy!!

prasoonbatham: 2016-10-19 16:32:38

Take input as a string. Remember how floating points are stored. :)

coder_hsnake: 2016-10-14 00:24:07

finally happy to remove it from my todo list after a long time though lots of WAs for this ques :-))


Added by:cegprakash
Date:2012-10-12
Time limit:0.185s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All except: ASM64