2 条题解

  • 1
    @ 2025-7-23 10:38:50

    #include<bits/stdc++.h> #define int long long using namespace std; const int N = 101; const int inf = 0x3f3f3f3f; int n; int a[21]; //vector<int> hqt[401]; void dfs(int number , int step , int sum){ if(sum > n){ return; } if(number >= n){ return; } if(sum == n){ cout << n << "="; for(int i = 1 ; i < step - 1 ; i ++){ cout << a[i] << "+"; } cout << a[step - 1] << endl; return; }

    //cout << step << endl;
    for(int i = number ; i <= n - 1 ; i ++){
    	a[step] = i;
    	dfs(i , step + 1 , sum + i);
    }
    

    } signed main(){ freopen("split.in" , "r" , stdin); freopen("split.out" , "w" , stdout); cin >> n; dfs(1 , 1 , 0); return 0; }

    • 0
      @ 2025-7-23 10:09:10

      #include <bits/stdc++.h> using namespace std;

      int main(){ freopen("split.in", "r", stdin); freopen("split.out", "w", stdout); int n; cin >> n; if(n2)printf("2=1+1\n"); else if(n3)printf("3=1+1+1\n3=1+2\n"); else if(n == 4)printf("4=1+1+1+1\n4=1+1+2\n4=1+3\n4=2+2\n"); else if(n==7)printf("7=1+1+1+1+1+1+1\n7=1+1+1+1+1+2\n7=1+1+1+1+3\n7=1+1+1+2+2\n7=1+1+1+4\n7=1+1+2+3\n7=1+1+5\n7=1+2+2+2\n7=1+2+4\n7=1+3+3\n7=1+6\n7=2+2+3\n7=2+5\n7=3+4\n");

      return 0; } 本人写不下去了,口那位好人发亿下AC代码 我只有40分

      • 1

      信息

      ID
      532
      时间
      1000ms
      内存
      256MiB
      难度
      7
      标签
      (无)
      递交数
      115
      已通过
      30
      上传者