Submit | All submissions | Best solutions | Back to list |
VENOM - Touch of Venom |
Sometimes you have to try fighting even though you know that your enemy is very powerful than you. Your hero with initial health H is about to fight against a venomous enemy who has a poisonous value of P. The enemy's poison deals i*P damage at it's ith attacking chance(i>=1). The hero dies when his health becomes <=0. After enemy's attack, if the hero survives, he heals himself with a health of A by using his skills. Then the enemy gets the chance again and the cycle continues till the hero dies. Find the survival time of the hero. You can safely assume that the hero is mortal.
Example Scenario:
Initial Health(H) = 10, Poison (P) = 2, Heal value(A) = 1
At time 1, enemy does 1*2 damage reducing the hero's health to 8
At time 2, hero heals himself by 1 increasing his health to 9
At time 3, enemy does 2*2 damage reducing the hero's health to 5
At time 4, hero heals himself by 1 increasing his health to 6
At time 5, enemy does 3*2 damage and kill the hero.
The hero survived 5 units of time.
Input:
The first line consists of an integer t, the number of test cases. For each test case there is a line with 3 integers H, P and A.
Output:
For each test case, find the survival time of the hero.
Input Constraints:
1<=t<=10^6
1<=H<=10^6
1<=P<=10^6
0<=A<P
Sample Input:
3
3 7 2
81 4 1
87 8 4
Sample Output:
1
13
9
Added by: | cegprakash |
Date: | 2014-03-10 |
Time limit: | 1s |
Source limit: | 50000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Languages: | All except: BF |
hide comments
|
|||||||||
2015-10-17 14:36:21
Nice... |
|||||||||
2015-10-02 18:04:48 Shubham Garg
Why does double give tle ? whereas int is accepted. |
|||||||||
2015-10-02 08:44:28 rahul_verma
find [spoiler removed] !!! loop gave TLE Last edit: 2015-10-17 17:35:38 |
|||||||||
2015-08-16 07:52:20 ROHIT Kumar
use printf ,scanf for input...in c++ by using #include <bits/stdc++.h> use of cin and cout gaves me tle |
|||||||||
2015-08-09 14:43:10 Anant Upadhyay
Good use of quadratic inequation...... worth solving! |
|||||||||
2015-08-04 22:27:44 MishThi
Repeatedly TLE in Python.. Time limit is too strict for languages like Python. |
|||||||||
2015-08-04 19:32:10 alok singh
one wrong ans due to silly mistake :p |
|||||||||
2015-08-04 19:03:40 shantanu tripathi
accepted in one go.. :) power of t boys |
|||||||||
2015-07-21 08:24:24 MishThi
Back to back NZEC errors despite correct answer on ideone :( |
|||||||||
2015-07-21 06:00:33 [Mayank Pratap]
using input variables of double data type gives TLE ,,,while int gives AC ...Can anybody give a hint why is this happening?? |