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
pika_pika: 2013-07-04 17:54:56

all this time i was using %I64u flag for scanf and long long and that gave WA infinite times while it worked superbly on my system with gcc 4.7.1 but the second i changed it to %Lu i got no output on my sys but AC on ideone and spoj.. why??? the gcc versions are same aren't they... ???

Mohit Gupta: 2013-06-23 22:44:04

@Devil D
Getting WA :(
ID - 9538028
Plz check
Got AC finally

Last edit: 2013-06-24 21:45:46
Vaibhav Yenamandra: 2013-06-21 21:35:02

@Devil D please help me with this TLE...
Any pointers/tips would do :|
Submission id: 9526047
Edit: AC finally!

Last edit: 2013-07-12 14:29:31
Hariharan : 2013-06-16 18:46:46

getting a WA,though it works perfectly on ideone!! :-(

Erti-Chris Eelmaa: 2013-06-15 21:03:06

For C# it's too strict. I tried few optimization tricks(such as using StringBuilders and doing raw stuff + declaring variables outside of scope), but noway. Don't waste your time.

Last edit: 2013-06-15 21:03:17
Alien: 2013-06-09 02:20:12

to avoid TLE print the series as a+(i*d) where max value of i is no of terms in series

ankit kumar sinha: 2013-05-30 16:35:26

beware of last "\n"... no \n at last .. gave me a wrong answer.

shashank: 2013-05-22 04:28:28

Very Simple ,
remember to use long long in C
and a small hint , 1st+last term =2nd+2nd last term.
sum=(1st+nth term)/2
Carry On.

Last edit: 2013-05-22 04:29:20
Parshant garg: 2013-05-09 21:03:35

input:6 6 30
two answers are possible.. which we have to in output..
4 5 6 7 8
2 4 6 8 10

suryadev: 2013-03-31 19:23:33

if you are getting TLE although you sol producing correct result then do some changes in the for loop condition ,updation and simplify it , deletion of even a single unwanted code make your sol AC

Last edit: 2013-03-31 19:24:13

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