Submit | All submissions | Best solutions | Back to list |
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
|
||||||||||||||
2016-11-13 06:36:04
Watch out for traps! :) |
||||||||||||||
2016-11-12 12:38:59
make sure that your algorithm has O(n) complexity for this problem |
||||||||||||||
2016-10-03 09:10:01
what could be the reasons for getting WA? I did the math and cross checked other solutions online and they use the same logic. I am getting correct output for test cases. |
||||||||||||||
2016-09-08 21:49:06
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) |
||||||||||||||
2016-09-08 21:47:37
I dont know how can we even get tle. It is really a simple problem. Just arithematic. Only loop i used was to print number . |
||||||||||||||
2016-09-08 21:46:48
DO NOT BE SCARED BY READING COMMENTS TOUGH PROBLEM , TIME LIMIT EXCEEDED. The Problem Is EASY . just think on our own. Do not read comment and get scared and use their approach instead of yours. I did it it in C. Was Printing Only first 10 numbers so Got Wrong Answer Many Times. Just Be Careful of the case when d = 0. I Don't Know whether it can be a test case. But being careful does not hurt. Last edit: 2016-09-08 21:50:05 |
||||||||||||||
2016-06-27 15:03:03 Rahadian Koesdijarto Putra
Hint: define every member of the AP using f(n) = a+(n-1)b, then you can find the rest. |
||||||||||||||
2016-06-19 13:32:59
used c++ : tle used c : ac -_- Last edit: 2016-06-19 13:44:29 |
||||||||||||||
2016-06-16 16:44:49
Pure Mathematics!!! #Ac In one GO |
||||||||||||||
2016-06-09 14:38:36
TLE in Java Use C/C++ |