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
Lai Manh Tuan: 2013-01-11 06:05:02

just use some basic precalculus

VARUN KUMARE: 2013-01-03 09:23:50

Hello guys! it is happiest moment for me bcz solving this prblm i get 0.1 point...
also try it---
I/P -
2
6 16 110
15 140 2325
O/P:
10
2 4 6 8 10 12 14 16 18 20
30
5 10 15 20 ... 135 140 145 150

u can also use concept to easily solve this problem "the sum of the terms equidistant from the beginnig and end is always constant"

Muhammad Rizky Luthfianto: 2012-12-12 03:00:34

Not enough time limit for Ruby or even Java

Paul Draper: 2012-12-10 04:44:58

Time limit is a little extreme. JVM takes ~0.25 second to start.

gourav: 2012-11-09 11:25:24

hell... i was just not printing the value of n...got damn WA just bcz of this mistake :'( irritated

Francky: 2012-10-01 21:37:50

Warning : in one or more input file, the last '\n' is missing !!!

Aayush Bahuguna: 2012-09-24 23:28:35

Take Care if d = 0 :)

AC Srinivas: 2012-08-17 10:09:23

any tricky test cases? what if c(sum)=0? then many series are possible.
if a=5,b=-5,sum=0 then both series are possible
9 7 5 3 1 -1 -3 -5 -7 -9
7 6 5 4 3 2 1 0 -1 -2 -3 -4 -5 -6 -7

Prakash Murthy: 2012-08-11 12:57:26

Looks like the time limit is still too small for Ruby. No successful submissions so far. And I got TLE with the optimum algorithm.

nagato: 2012-08-11 11:12:57

easy one

Last edit: 2012-08-11 11:21:06

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