提交时间:2023-11-04 09:47:57

运行 ID: 108730

#include<bits/stdc++.h> using namespace std; int pl [114514] = { 1 } ; int x , tot = 0 ; void dfs ( int a , int k ) { for ( int i = pl [k - 1] ; i <= a ; i ++ ) { if ( i < x ) { a -= i ; pl [k] = i ; if ( a == 0 ) { cout << x << '=' ; for ( int j = 1 ; j < k ; j ++ ) { cout << pl [j] << '+' ; } cout << pl [k] << endl ; tot += 1 ; return ; } else { dfs ( a , k + 1 ) ; } a += i ; pl [k] = 0 ; } } return ; } int main() { cin >> x ; dfs( x,1 ) ; cout << tot << endl ; return 0 ; }