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
2014-09-18 18:01:32 Nand kishore
I dont think it can be done in java. its just formula, how could u save time in formula.
2014-09-12 21:23:05 vikax
easy one ac in 1 go
2014-09-11 11:53:49 Arun Karthikeyan
Damn time limit too strict for Java, there isn't even a single AC solution in Java.
2014-08-30 12:36:01 Rajat (1307086)
formula based stuff.Try dis case
1
4 4 28

7
4 4 4 4 4 4 4
2014-08-07 20:48:20 Rohit Palivela
@KrishnaRathi n>=7
2014-07-20 07:36:06 S
I think the time limit might be too strict for Java. Reading the entire file into memory before processing didn't work.

Porting to C++ got AC.
2014-07-13 18:18:25 OneMoreError
AC in 1 gooO !!
kudos ^-^....well..2day is final of arg vs ger .....hope germany wins...muller will steal d show
2014-07-10 14:12:32 Sanket Dasgupta
Time limit too strict for interpreted languages. >:(
2014-07-01 18:07:53 Mitch Schwartz
@Krishna Rathi and others who wrote similar comments: be sure to read the "NOTE" at the bottom of the problem statement.
2014-07-01 16:27:53 jetpack
@Devil D:
if the third term and third last term of the series are same,there are two possible solutions.
4 4 20
can give 4 4 4 4 4
or 2 3 4 5 6
cost me 2 WA :(
© Spoj.com. All Rights Reserved. Spoj uses Sphere Engine™ © by Sphere Research Labs.