1 solutions

  • 0
    @ 2024-10-17 21:12:21
    #include<bits/stdc++.h>
    using namespace std;
    int n,ans = 0;
    void dfs(int x,int cnt) {
    if (x == 0) {
    ans++;
    return;
    }
    if (x<0){
    return;
    }
    for (int i = cnt;i <= n;++i) {
    dfs(x-i,i);
    }
    }
    int main() {
    cin >> n;
    dfs(n,1);
    cout << ans;
    return 0;
    }
    

    Information

    ID
    598
    Time
    1000ms
    Memory
    256MiB
    Difficulty
    7
    Tags
    # Submissions
    13
    Accepted
    11
    Uploaded By