提交时间:2023-11-04 09:09:13
运行 ID: 108636
#include<bits/stdc++.h> using namespace std; int a[55]={1},n,toal; int sou(int ,int); int p(int); int main() { //freopen("split.in","r",stdin); //freopen("split.out","w",stdout); cin>>n; sou(n,1); cout<<toal<<endl; } int sou(int s,int t) { int i; for(i=a[t-1];i<=s;i++) if(i<n) { a[t]=i; s-=i; if(s==0) p(t); else sou(s,t+1); s+=i; } } int p(int t) { cout<<n<<"="; for(int i=1;i<=t-1;i++) cout<<a[i]<<"+"; cout<<a[t]<<endl; toal++; }