Sphere Online Judge



SPOJ Problem Set (classical)

12448. HOW MANY GAMES

Problem code: 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


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 except: SCM chicken

hide comments
2015-01-27 23:08:56 SAKSHAM AGRAWAL
beware of floating pt errors costed me 1WA
2015-01-14 21:37:18 Subodh Yadav
good question and must for beginners :)
2015-01-07 19:21:23 rahul goyal
very gud questn (y)
2014-12-24 17:50:44 Anand Namdev
u have python , u have power !!!
2014-12-18 13:49:41 Kushal Singh
well ...just so that you know ...using double might not be a good idea :P
2014-09-18 13:30:03 shivam kumar
if avg = 3.3333
then no. of matches = 10 is correct or not
2014-08-03 18:37:29 Bodh Almast
any tricky test case?
i tried
999999.9999 -> 1000
2014-07-13 06:14:40 kiran pilli
learnt a new thing..nice problem
2014-07-12 23:12:51 ήάέέϻ
nice and easy :) good question :)
2014-07-07 18:36:17 pandu ranga rao
Constraints helped me... nice one
© Spoj.com. All Rights Reserved. Spoj uses Sphere Engine™ © by Sphere Research Labs.