AP2 - AP - Complete The Series (Easy)

no tags 

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
Akshay Aradhya: 2015-07-17 11:55:03

Btw it is Arithmetic* (Spell Check)

Dilpreet: 2015-07-12 12:38:35

Got TLE in JAVA and AC on c++ for the same solution

scyth3r: 2015-07-07 08:17:25

why is the same code, which had got accepted, giving me TLE?? -_-

Souvik Mondal : 2015-06-28 20:19:35

Can someone who got AC in python share the logic.
Getting TLE in python,same logic AC in c

karthik1997: 2015-06-28 13:22:36

got ac in first go :p :)

Akash Singh: 2015-06-13 12:41:59

Still have no clue, how some of the users got AC using Python.

rudra21: 2015-06-10 22:25:45

third_num = a + 2d
third_last = a + (n-3)d
sum of n term = (n/2)(2a + (n-1)d)
work around above three formula.

Akash Goel: 2015-06-10 14:41:14

Couldn't AC in C++ but using same code got AC in C.

Shashank kumar: 2015-05-24 11:55:45

i just spent one hr thinking what wud happen when n=5 ; and guessed what it was in vain ... it really sucks

rpc1: 2015-05-19 21:22:49

This is a stupid problem, imprecisely stated and the time limit is all the more stupid. There was no need to write the whole series, enough was writing the delta and length, possible the starting and ending elements. The time limit is really useless because the output for a very long series will take time in a high level language like python.
For example, the following output would cause a timeout:

print u' '.join(str(m + i*delta) for i in xrange(slen))

which is perfectly normal idiomatic python.
Please downvote!!


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