提交时间:2023-11-04 09:10:08
运行 ID: 108651
#include<bits/stdc++.h> using namespace std; int a[10001]={1},n,total; int print(int t){ cout<<n<<"="; for(int i=1;i<t;i++){ cout<<a[i]<<"+"; } cout<<a[t]<<endl; total++; } int dfs(int cur,int t){ int i; for(i=a[t-1];i<=cur;i++){ if(i<n){ a[t]=i; cur-=i; if(cur==0){ print(t); } else{ dfs(cur,t+1); } cur+=i; } } } int main(){ //freopen("split.in","r",stdin); //freopen("split.out","w",stdout); cin>>n; dfs(n,1); cout<<total; return 0; }