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
2013-12-28 16:54:04 lihaitao
WA 5 times.Finally,I found I should use "%lld",not "%I64d"!
2013-12-20 18:15:13 Praneeth
Some simple math involved to slove by using the inputs and got ac:) in first attempt
2013-12-08 19:27:06 Gabriel Siedler
Impossible to solve in time with C#.
2013-11-22 23:29:42 Zachary Fakename
Edit:
While this insight seems trivial, it gave me some head ache. For the output, don't try to loop (val += stepsize) until (val == x_n).
[spoiler]It can happen that val == x_i == x_n with i != n[/spoiler]

Last edit: 2013-11-22 23:42:41
2013-09-23 08:25:19 swagnik dutta
@Devil D i didn't see a single successful solution in java and ruby till now http://www.spoj.com/ranks/AP2/lang=JAVA.
http://www.spoj.com/ranks/AP2/lang=RUBY

My solution(<snip>) gets TLE. Can you please increase the time limit for java?

Last edit: 2023-02-04 22:24:47
2013-08-16 09:53:40 intriguer


Last edit: 2013-08-19 07:55:50
2013-07-21 19:51:48 zulfiqar murhej
please can anyone help me with strong test cases
can anyone tell me what is the answer of this test case

2
144115188075855890 144115188075856304 7349874591868660947
144115188075856304 144115188075855890 7349874591868660947

2013-07-17 11:21:25 Joey Tribbiani
@Devil D
Please check out submission no. 9669871
Please point out any errors?
Cant figure any
2013-07-12 19:18:21 Akshita Agarwal
i am confused...should there be an endl after every output test case??
2013-07-05 14:52:11 ..........
Accepted in first strike
© Spoj.com. All Rights Reserved. Spoj uses Sphere Engine™ © by Sphere Research Labs.