AP2 - AP - Complete The Series (Easy)

no tags 

Arithmatic and geometric Progressions are 2 of the well known progressions in maths.

Arithmatic 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 & 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
samriddhi07: 2019-06-17 18:42:53

Seriously! Spoj hates Java. Same code in C got AC and in java WA.

klmo: 2019-04-26 17:12:49

spoj hates java!!

hritwik: 2019-03-27 15:46:31

dont forget to take numbers in long long int

snoofer: 2019-03-23 20:03:04

python take lots of time

: 2019-03-23 14:49:19

pure high school maths and equations nothing else. very easy question.

sarthak_1998: 2019-03-22 21:55:23

@true_saiyan it is written that The series will have at least 7 elements. So there is no chance for both to be equal.

anant6025: 2019-02-05 22:43:42

Just one thing you need to know:

(1st term + last term) = (2nd term + 2nd last term)= (3rd term + third last term) and so on..
rest all is simple, also no need to go into quadratic equations.

ankit0kanth: 2018-12-29 13:25:03

is it possible to solve in java? because of time constraint. please advice.

adarshtadwai: 2018-10-18 13:26:28

1st term + last term = 2nd term + last 2nd term = 3rd term + last 3rd term
this observation is helpful and directly gives n

harshjalan_99: 2018-09-29 18:25:18

Last edit: 2018-09-29 18:26:28

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