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-22 11:47:41 HWK
@C: Bye-bye :-) |
||||||
2011-06-21 19:48:49 Piotr KÄ…kol
@HWK - Hmm. As I said, I don't know what hint to give. If You knew what's the trick You would agree with me that it's difficult to describe it. I can say that it's not connected with the algorithm AT ALL. ;-) But still, You may shorten Your algo as well. ;-) I knew You'll reach these 121 chars in Pyth. :-) We'll see how short will be numerix's and hallvabo's codes. ;-> |
||||||
2011-06-21 18:24:39 HWK
@Piotr: I feared that because you shortened to 123 without removing the =. My remaining ideas don't work at the moment. So what about a little hint? ;-) Meanwhile I'll look at Python. :-) Edit: Python ahead C again. Last edit: 2011-06-21 18:32:35 |
||||||
2011-06-21 11:49:41 Piotr KÄ…kol
@HWK - Once again, great job. :-) Sorry for making You mad but I removed the one byte again. One more and again Python will be beaten (unless You shorten it with another byte). :-) Last edit: 2011-06-21 11:56:51 |
||||||
2011-06-21 10:52:30 HWK
@Piotr: Always the same - after sleeping a night the solution is so obvious. As you'll see there are two variants. Perhaps you could get new ideas from them. By the way: I removed the <=. :-) Last edit: 2011-06-21 10:53:13 |
||||||
2011-06-20 21:25:22 Piotr KÄ…kol
@HWK - No, but You can try to remove bytes wherever You want. ;-) |
||||||
2011-06-20 19:04:16 HWK
Sometimes sleeping a night helps. So let's see. By the way: My C solution helped advancing the Python one. Edit: Oh, you shortened another byte. Have you removed the <=? Last edit: 2011-06-20 19:35:24 |
||||||
2011-06-20 19:02:32 Piotr KÄ…kol
@HWK - Agree, nice duet. :-) But why it's enuogh? :-( We still have to reach 11^2 to beat Your Python solution. ;-) |
||||||
2011-06-20 18:55:46 HWK
@Piotr: Okay, 124 bytes too. I think that's enough shortening for C. :-) Looks like we're a good team for shortening. Challenging one another. ;-) Last edit: 2011-06-20 19:04:31 |
||||||
2011-06-20 18:38:20 Piotr KÄ…kol
@HWK - 122 chars. Nice. :-) I have no idea how to shorten "my" :P code. Maybe You'll find another trick trying to remove one more. And yes, Your reading is now perfect. :-) |