Submit | All submissions | Best solutions | Back to list |
GP1 - GP - Complete the Series v1 () |
Geometric progression (GP) is a set in which the ratio of 2 consecutive numbers is same. for example: 1, 2, 4, 8, 16 - in this case, the ratio of the numbers is 2.
The task here is very simple indeed. You will be given the 3rd term, 3rd last term and the sum of the series. You need print length of the series and the series.
Input
First line will contain a number indicating the number of test cases.
Each of the following t lines will have 3 number '3term', '3Lastterm' and 'sum'
3term - is the 3rd term in of the series,
3Lastterm - is the 3rd to last term of the series,
sum - is the sum of the series.
Output
For each input of the test case, you need to print 2 lines.
fist line should have 1 value - the number of terms in the series.
2nd line of the output should print the series numbers separated by single space.
Example
Input: 1 4 64 511 Output: 9 1 2 4 8 16 32 64 128 256
NOTE
- All the values will be in the range [0, 264] inclusive.
- The series will have at least 6 elements.
- Number of test cases ≤ 100.
- The ratio in all cases will be an integer. (Thanks Mitch for pointing this out.)
- All the numbers will fit in 64 bits (long long in C.)
Added by: | Devil D |
Date: | 2012-03-26 |
Time limit: | 1s |
Source limit: | 10000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Languages: | All except: ASM64 |
Resource: | Own |
hide comments
2019-07-19 18:22:20 David
1 of 2 Java solvers! |
|
2017-03-09 18:35:07
Don't use power function,use simple multiplication using loop. |
|
2017-02-02 20:25:59
Don't use log function and for 5th degree eqn, don't use power function multiply r into no. of times as in eqn. |
|
2016-05-07 21:21:31 Sushovan Sen
Be careful. r may be 1. Last edit: 2016-05-07 21:26:46 |
|
2015-12-20 12:26:23
just a little trial and error. HINT:get a 5th degree polynomial equation DO NOT get afraid of the time interval. AC in 1 go :) |
|
2015-12-15 13:29:48 Siddharth Singh
Probably the best question i solved AC after 3 RE , 2 Different Logics , Both AC <3 Loving it |
|
2015-01-27 16:21:08 Adarsh Tiwari
yr floating error kya hai be |