提交时间:2023-10-08 14:01:53
运行 ID: 105879
#include<iostream> using namespace std; int p[55],x=0,y=0,o=0,c=1; int a; int st(int l){ if(c<=l){ for(int i=c;i<=l;i++){ x++; p[x]=i; c=i; if(l-i>c){ st(l-i); }else{ if(l-i==0){ cout<<a<<"="; for(int q=x;q>1;q--){ cout<<p[q]<<'+'; } cout<<p[1]<<endl; x=0; y++; c=1; } } } } } int main(){ cin>>a; st(a); cout<<y; return 0; //2= 1 1 1 }//3=1 1 1 2 //1 2 //4=1 1 1 1 4 //1 1 2 //2 2 //3 1 //5=1 1 1 1 1 6 //2 1 1 1 //2 2 1 //3 1 1 //3 2 //4 1 //6 1 1 1 1 1 1 10 //2 1 1 1 1 //2 2 1 1 //2 2 2 //3 1 1 1 //3 2 1 //3 3 //4 1 1 //4 2; //5 1;