提交时间:2023-12-20 14:01:18
运行 ID: 116913
#include<bits/stdc++.h> using namespace std; int n,ans,a[1000001]; void dfs(int step,int sum,int minn){ if(sum==n){ cout<<n<<"="; for(int i=1;i<step-1;i++) cout<<a[i]<<"+"; cout<<a[step-1]<<endl; ans++; return; } if(sum>=n) return; for(int i=minn;i<n;i++){ a[step]=i; dfs(step+1,sum+i,max(minn,i)); a[step]=0; } } int main(){ cin>>n; dfs(1,0,1); cout<<ans; return 0; }