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)
hide comments
garmel:
2015-10-31 01:09:57
hmmm....It will usefull if you think of the subtraction of the two first terms and the two last ones....u-r+u-2r
|
|
darkhire21:
2015-10-27 21:53:00
@ANKIT KUMAR
|
|
kiner_shah:
2015-10-02 19:08:48
Getting time limit exceeded using c++! Just used one for loop to display the numbers! |
|
dk619:
2015-09-30 10:15:51
Think of T3 in terms of n-1 and n-2, i.e. Split T3 |
|
khalidmuhumed:
2015-09-24 09:17:38
For java users...it will most likely be TLE....use C++ or better yet C. The time limit is very stupid and didn't take into consideration different languages...costed me 5 wrong answers. Got Accepted in C finally...:( |
|
pvsmpraveen:
2015-09-02 16:45:23
When you apply the formula, and you have got a wrong answer.....
|
|
amous_19291:
2015-08-28 10:53:57
very eassy question......the given time limit is enough.....:p
|
|
KD :
2015-08-23 08:15:39
AC in first go very easy prob. :p
|
|
swapnil3895:
2015-08-20 18:57:30
AC in first go ^_^ |
|
Manish Das Mohapatra:
2015-08-11 17:55:12
Think about the summation of Nth term from first and Nth term from last.
|
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 |