Submit | All submissions | Best solutions | Back to list |
AP2 - AP - Complete The Series (Easy) |
Arithmetic and geometric Progressions are 2 of the well known progressions in maths.
Arithmetic progression (AP) is a set in which the difference between 2 numbers in constant. for e.g., 1, 3, 5, 7, 9 ... In this series the difference between 2 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 and
3Lastterm - is the 3rd term in of the series and
sum - is the sum of the series.
Output
For each input of the test case, you need to print 2 lines.
First 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 3 8 55 Output: 10 1 2 3 4 5 6 7 8 9 10
NOTE:
- In all the test cases, all the series elements are positive integers.
- The series will have at least 7 elements.
- number of test cases <=100.
- All the numbers will fit in 64 bits (long long in C)
Added by: | Devil D |
Date: | 2012-03-13 |
Time limit: | 0.100s |
Source limit: | 1500B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Languages: | All except: ASM64 |
Resource: | Own |
hide comments
|
||||||||||||||
2015-05-16 17:49:25 Devendra Gurjar
Help admin. I remove the condition of floating point error still it shows SGIFPE. plzz help. |
||||||||||||||
2015-04-15 13:40:32 Prasanna Patil
Same logic in Python and C Python got TLE C got AC in 0.00 time limit Though there arr AC solution in Python, i have no idea of logic they have used. Thnx @rajat for that test case. Last edit: 2015-04-15 13:41:38 |
||||||||||||||
2015-03-07 02:46:35 Zhenxi Chen
but it said 7 elements at least.@Feroz Ahmad |
||||||||||||||
2015-02-19 14:55:51 Fz
No test cases checking the submitted solution for the case when you calculate and obtain; n=5 eg: 6 6 30 where possible answers can be more than one set |
||||||||||||||
2015-02-16 14:10:49 dumb
guys dont take difference as double take it long long int |
||||||||||||||
2015-02-11 19:04:52 Andrey Kaygorodov
Got AC in C. I couldn't manage to solve it by using java. |
||||||||||||||
2015-02-09 01:19:52 Aditya
"\n" not giving any problem. I have tried |
||||||||||||||
2015-02-01 08:33:10 Andrey Kaygorodov
It seems not possible to meet time limits if you use java. |
||||||||||||||
2015-01-30 14:30:07 U-Me Nakam
series will have at least 7 elements...@amit jaiswal |
||||||||||||||
2015-01-17 16:27:45 Dushyant Singh
Got AC after several attempts because i was not using long long int! |