Submit | All submissions | Best solutions | Back to list |
AP3 - AP - Complete The Series v2 |
After solving "AP - Complete The Series (easy)" very fast, Lucifer decided to make it little more interesting.
He said
He will be give you the 3rd term, 4th last term and the sum of the AP 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' ,'4Lastterm' and 'sum'
3termĀ - is the 3rd term in the series and
4LasttermĀ - is the 4th last term in 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 - number of terms in the series.
second line of the output should print the series numbers separated by single space.
Example
Input: 1
3 7 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: | 10000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Languages: | All except: ASM64 |
Resource: | Own |
hide comments
|
|||||||||||||
2019-12-01 19:22:24 cegprakash
if n can be 64 bits it would take years to print the results. For eg. this case 1 1 1 1000000000000000000 Please give an upper cap on n Edit after solving: Submit your solution in python first. You'll realize you don't even need 16 bits to store n. Then try in C++ without bigint / float / double :) Last edit: 2019-12-01 21:09:32 |
|||||||||||||
2019-03-16 15:33:47
@Devil could you please let me know the flaw in my code, id - 23423975 |
|||||||||||||
2018-12-19 15:21:05
Easy my 60th AC :) Don't forget to use llrint keep precision in mind |
|||||||||||||
2018-01-04 15:19:30
"The series will have at least 7 elements" took this line wrongly by thinking,we hv to print upto min.7 elements only..which cause me 2 WA u hv to prnt upto n elements.... :) |
|||||||||||||
2017-06-18 23:14:18
Finally AC. :) Use Simple Maths & Solve Quadratic. Use sqrtl() & llrint() for avoiding WA due to precision error. :) |
|||||||||||||
2017-02-04 11:29:38
Separately handle the case when all the elements of the series will be equal . |
|||||||||||||
2015-09-03 17:34:15
GOT AC!! Some comments may drive you away from the problem, i did nothing with precision in this problem, ALL TERMS ARE GIVEN INTEGERS Last edit: 2015-09-03 17:38:21 |
|||||||||||||
2015-06-29 16:11:25 Adarsh Tiwari
can any one tell me that why it is not accepting my code as in ap2 . |
|||||||||||||
2015-06-22 15:35:13 jas.py
use llrint |
|||||||||||||
2015-06-12 11:22:54 SHRINIKET ACHARYA
if u r using double,use it correctly in every operation :) |