Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Kalin Iliev
- #include <iostream>
- using namespace std;
- const int MAX_X = 10000;
- void NoName(int x, int used[])
- {
- if (x == 0)
- {
- for (int i = 1; i < used[0]; i++)
- {
- cout << used[i] << " ";
- }
- cout << endl;
- }
- else if (x < 0)
- {
- cout << "ERROR!!!\n";
- }
- else
- {
- for (int i = used[used[0]-1]; i <= x; i++)
- {
- if (x - i >= i || x - i == 0)
- {
- used[used[0]++] = i;
- x -= i;
- NoName(x, used);
- used[0] --;
- x += i;
- }
- }
- }
- return;
- }
- int main ()
- {
- int x;
- cin >> x;
- int used[MAX_X+1];
- used[0] = 1;
- NoName(x, used);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement