avinash.it09
BAN USER- 0of 0 votes
AnswersFoo was not amongst the most brilliant students of his class. So, he has some pending exams to clear. As the exams are approaching, this time he vowed to pass in all of them. This will only happen if he is not under stress. Foo's stress can be calculated using a simple function called Foo_function which depends upon the time for which Foo studies continuously .
- avinash.it09 in India
Foo_funtion is defined as follows:
F(t)=A(t^3)+B(t^2)+C*(t)+D, F(t)<=10^18
where A,B,C,D belong to the set of prime numbers. t is the time in minutes for which foo studies continuously.
As foo is not very good at solving cubic equations, he seeks your help to find out the maximum number of minutes for which he can study continuously without taking stress. Help him find t such that F(t+1) > K, and F(t) <= K, where K is the maximum stress Foo can bear.
Input:
The first line of the input contains a single integer T denoting the number of test cases. each test case consists of a single line containing 5 space seperated positive numbers a, b, c, d, K.
Output:
for each test case, output a single integer t denoting the maximum time for which foo can study continuously without taking stress.
Constraints:
1 <= T <= 10^4
A, B, C, D belong to a set of prime numbers such that F(t) would never exceed 10^18
t >= 0
1 <= K <= 10^18
Sample Input (Plaintext Link)
2
2 2 2 2 10
2 3 5 7 1000
Sample Output (Plaintext Link)
1
7
Explanation
In the 1st test case for t = 2 foo will be under stress because F(2)=30 > K, therefore he can study for a maximum time of 1 minute without having stress.
In the 2nd test case for t = 8 foo will be under stess because F(8)=1263 > K, therefore he can study for a maximum time of 7 minutes continuously without having stress.
Time Limit 5 sec(s) (Time limit is for each input file.)
Memory Limit256 MB
Source Limit1024 KB| Report Duplicate | Flag | PURGE
InMobi SDE1 Algorithm - -1of 1 vote
AnswersGiven a integer N, print the decimal form of 1/2n.
- avinash.it09 in India
Example:
N=1, print 0.5
N=2, print 0.25
Adding leading/unsignificant zeroes will lead to wrong answer. Example, printing 0.50 instead of 0.5 in above case will lead to wrong answer.
Input and Output:
First line contains T, the number of testcases. Each testcase consists of N in one line.
Print required answer in one line for each testcase.
Constraints:
1 ≤ T ≤ 100
1 ≤ N ≤ 200
Sample Input (Plaintext Link)
2
2
1
Sample Output (Plaintext Link)
0.25
0.5
Explanation
You need to print output in decimal form only. There is no limit on number of decimal digits in output.
So correct output of 100 will be "0.0000000000000000000000000000007888609052210118054117285652827862296732064351090230047702789306640625"
Time Limit1 sec(s) (Time limit is for each input file.)
Memory Limit256 MB
Source Limit1024 KB| Report Duplicate | Flag | PURGE
InMobi SDE1 - 0of 2 votes
AnswersUse smart ways to find prime factors and then arrive at the result for large A & B in input. Bruteforce won't work.
- avinash.it09 in United States
Given A,B print the number of pairs (a,b) such that GCD(a,b)=1 and 1<=a<=A and 1<=b<=B.
Input:
First line contains an integer T, the number of testcases. Each of next T lines contains two space separated integers denoting Aand B.
Output:
Output T lines, each containing single integer, the required output for each test-case.
Constraints:
1 <= T <= 10
1 <= A <= 10^5
1 <= B <= 10^5
Sample Input (Plaintext Link)
1
3 2
Sample Output (Plaintext Link)
5
Explanation
1,1
1,2
2,1
3,1
3,2
Time Limit5 sec(s) (Time limit is for each input file.)
Memory Limit256 MB
Source Limit1024 KB| Report Duplicate | Flag | PURGE
Amazon SDE1