提交时间:2023-11-04 09:09:32
运行 ID: 108642
#include<bits/stdc++.h> using namespace std; int a[10001]={1},sum,n; int print(int t){ cout<<n<<"="; for(int i=1;i<=t-1;i++){ cout<<a[i]<<"+"; } cout<<a[t]<<endl; sum++; } int search(int x,int y){ for(int i=a[y-1];i<=x;i++){ if(i<n){ a[y]=i; x-=i; if(x==0) print(y); else search(x,y+1); x+=i; } } } int main(){ cin>>n; search(n,1); cout<<sum; return 0; }