Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <cstdio>
- #include <vector>
- using namespace std;
- vector<int> vec;
- void print(){
- for(int i = 0; i < (int)vec.size(); ++i) printf("%d ", vec[i]);
- printf("\n");
- }
- void calc(int remain, int base){
- if(remain == 0){
- print();
- return;
- }
- for(int i = base; i <= remain; ++i){
- vec.push_back(i);
- calc(remain - i, i);
- vec.pop_back();
- }
- }
- int main(){
- int n;
- scanf("%d", &n);
- calc(n, 1);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment