AP3 - AP - Complete The Series v2

no tags 

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 & the series.


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.


For each input of the test case, you need to print 2 lines.

fist line should have 1 value- number of terms in the series.

2nd line of the output should print the series numbers separated by single space.





3 7 55


1 2 3 4 5 6 7 8 9 10

- 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
Ankit Paharia: 2012-04-06 09:54:51

Why am i getting WA for this...... plzz chk my solution ..... sub. ID 6653164 !!!

Devil D: 2012-04-06 09:54:51

@ Mehmet - the series is non-decreasing series....

mehmetin: 2012-04-06 09:54:51

Can the input be for a decreasing series?

Last edit: 2012-03-14 12:15:20
Mitch Schwartz: 2012-04-06 09:54:51

Oh, hmm, I can find many test cases where my submission 6646500 fails. For example

728190161165704306 728190161165682931 6553711450491210504
1018311893057538647 1018311893057538623 7128183251402770361

It gives wrong output for the first, and NZEC for the second. So, test cases could be stronger lol. (Submission 6647117 handles them fine.)

Mitch Schwartz: 2012-04-06 09:54:51

@Deepak: Ok that works. Still a little curious what the problem was before though. Thanks again.

Devil D: 2012-04-06 09:54:51

@Mitch - I modified the test cases and reduced the output constraints . After Rejudging your solution got accepted .. have disqualified few of your solutions though .

Mitch Schwartz: 2012-04-06 09:54:51

Thanks for the reply. Hmm, all I know is that problem PRIC mentions not to output more than 33 333 333 bytes, and that there is a SIGXFSZ error for trying to output more than allowed data. Since I got WA instead of SIGXFSZ, I guess it's some other issue.

It's mysterious.. I will try adding some defenses against possible badly formatted input and see if that does anything.

Thanks for working to figure out what's happening.

Devil D: 2012-04-06 09:54:51

@Mitch .. there are 5 test files ...For 3 files your output is printing less data ... for 1 test cases there are around 30 test cases but your solution is printing output for only 19 ...
I am not sure what the problem is ..IS there any limit to amount of data a solution can output ?

Let me try to find out the solution . If there is a limit i will try to modify the test cases for the same.

Mitch Schwartz: 2012-04-06 09:54:51

Hmm, I rewrote my code to be very defensive, and I checked it against thousands of random cases and the output seems ok. If it's not too much trouble, could you tell me a case for which my latest submission (ID 6647117) fails? Or else give reassurance that the test data is correct?

Added by:Devil D
Time limit:0.100s
Source limit:10000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All except: ASM64