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-01-11 06:05:02 Lai Manh Tuan
just use some basic precalculus
2013-01-03 09:23:50 VARUN KUMARE
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"
2012-12-12 03:00:34 Muhammad Rizky Luthfianto
Not enough time limit for Ruby or even Java
2012-12-10 04:44:58 Paul Draper
Time limit is a little extreme. JVM takes ~0.25 second to start.
2012-11-09 11:25:24 gourav
hell... i was just not printing the value of n...got damn WA just bcz of this mistake :'( irritated
2012-10-01 21:37:50 Francky
Warning : in one or more input file, the last '\n' is missing !!!
2012-09-24 23:28:35 Aayush Bahuguna
Take Care if d = 0 :)
2012-08-17 10:09:23 AC Srinivas
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
2012-08-11 12:57:26 Prakash Murthy
Looks like the time limit is still too small for Ruby. No successful submissions so far. And I got TLE with the optimum algorithm.
2012-08-11 11:12:57 nagato
easy one

Last edit: 2012-08-11 11:21:06
© Spoj.com. All Rights Reserved. Spoj uses Sphere Engine™ © by Sphere Research Labs.