Submit | All submissions | Best solutions | Back to list |
DIFFSUMS - Different sums |
Wersja polska | English version |
Input
The input consist of unknown number of tests. Each test is a line with one integer x (0<=x<25). The input ends with x=0 (for which You shouldn't print anything).
Output
For each test You should print all possible non-decreasing sequences of integers (which may occur more than one time) which totalled equal x. In each sequence the i-th number should be greater than, or equal to, the preceding number. The sequences themselves should also be sorted into numerically ascending order.
Example
Input: 1
2
3
4
5
0 Output: 1
1 1
2
1 1 1
1 2
3
1 1 1 1
1 1 2
1 3
2 2
4
1 1 1 1 1
1 1 1 2
1 1 3
1 2 2
1 4
2 3
5
Special thanks to Łukasz Kuszner for the concept of this task.
Added by: | Piotr Kąkol |
Date: | 2011-06-18 |
Time limit: | 1.666s |
Source limit: | 50000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Languages: | All except: SCM qobi |
hide comments
|
||||||
2011-06-20 16:23:28 HWK
@Piotr: But first we have to beat Python again. ;-) Edit: 2 bytes less again. Is this the shorter reading you mean? Last edit: 2011-06-20 18:55:10 |
||||||
2011-06-20 13:39:06 Piotr KÄ…kol
@HWK - Congratulations! :D Yes, Your reading can still be shorten. Apart from it there's at least one more trick (the one which I'm not able to describe). I removed next 3 chars. :-) One day we'll beat Jander in this task. :P Just "few" more chars. ;-) |
||||||
2011-06-20 12:02:44 HWK
@Piotr: Did it. One byte less Python. :-) The last 'trick' was so obvious that I had to miss it. My kind of input isn't the shortest? Thus you could shorten my solution anymore couldn't you? |
||||||
2011-06-19 21:06:45 Piotr KÄ…kol
@HWK - One with reading (still Yours isn't the shortest). Second... You were on a good path. And third... I don't know what hint to give. Maybe try shorten everything (including the algo) and perhaps You'll find another one. ;-) |
||||||
2011-06-19 18:44:22 HWK
@Piotr: But why it doesn't work? Edit: Clarified. So what are the other two tricks? Edit 2: Okay, one byte less. :) Edit 3: If hallvabo will find this task C will have no chance. Last edit: 2011-06-19 19:43:48 |
||||||
2011-06-19 18:34:48 Piotr KÄ…kol
@HWK - Yup, didn't change the algo and the idea is correct. :-) Two chars less. ;-) Not only did I change the input but also used two other tricks. ;-) Edit: Another two less. :D One more and C will be better than Python. :P Last edit: 2011-06-19 18:40:22 |
||||||
2011-06-19 17:34:20 HWK
@Piotr: Annoying. :-) I guess you didn't change my algo. Do you use a trick for input? Is the idea of 5269991 correct? Last edit: 2011-06-19 18:07:33 |
||||||
2011-06-19 17:23:35 Piotr KÄ…kol
@HWK - Here You are. :D |
||||||
2011-06-19 17:17:16 HWK
@Piotr: I'm awaiting new stimulations to improve the C solution. ;-) |
||||||
2011-06-18 20:03:11 Piotr KÄ…kol
Thanks. :-) Output specification changed. |