提交时间:2023-11-04 09:07:18
运行 ID: 108615
#include<bits/stdc++.h> using namespace std; int n,num[55],ans; void dfs(int a,int cnt){ if(!a&&num[1]!=n){ printf("%d=",n); for(int i=1;i<cnt;i++){ printf("%d",num[i]); if(i<cnt-1)printf("+"); } printf("\n"); ans++; return; } for(int i=max(1,num[cnt-1]);i<=a;i++){ num[cnt]=i; dfs(a-i,cnt+1); } return; } int main(){ //freopen("split.in","r",stdin); //freopen("split.out","w",stdout); cin>>n; dfs(n,1); cout<<ans; return 0; }