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


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

hide comments
kshitij_kohli: 2015-07-24 02:23:03

Why is this giving a wrong answer? I have checked all the testcases I could come across, and it seems to be working fine.
http://ideone.com/J7YNqC

ASHUTOSH DWIVEDI: 2015-07-11 21:15:50

WA using input as double
Why???? and using string AC..what the f***

Last edit: 2015-07-11 21:58:09
karthik1997: 2015-07-07 20:00:11

ac in 2 nd go .just
if number is 35.25 it is 3525/100 , caluculate gcd of 3525 and 100 that is gcd of numerator and denominator in that form only but not simplified form and divide that gcd /100; ,, imean denominator
use string rather than double to avoid tle and floating point errors :D

Sandeep N Menon: 2015-06-23 17:49:40

python giving TLE

Bhuvnesh Jain: 2015-06-13 16:19:21

to avoid floating point errors use int and char...
AC in one go.

:.Mohib.:: 2015-06-12 17:27:39

Nice que!!

shan_: 2015-06-05 12:26:22

Solved it using strings.
Can anyone please tell me the cases where floats give errors?

aloo: 2015-05-15 09:53:28

why is using double giving WA??

Siddharth Shah: 2015-05-12 19:57:57

can anyone give me few boundary cases. Giving me WA but all answers for boundary cases mentioned in comments are matching :(

Ankit Sultana: 2015-02-28 06:05:35

Can be done without strings per se