1 solutions

  • 0
    @ 2025-2-27 17:48:22

    本人是蒟蒻,此方法为某位大神分享。

    #include<bits/stdc++.h>
    using namespace std;
    const int N = 1e7,mod = 1e9+7;
    int n,a,b,c,dp[N];
    int main () {
    	cin >> n >> a >> b >> c;
    	for (int i = 0;i <= c;i++){
    		dp[i] = 1;
    	}
    	for (int i = c+1;i <= n;i++){
    		dp[i] = (dp[max(0,i-a)]+dp[max(0,i-b)])
            %mod;
    	}
    	cout << dp[n];
    	return 0;
    }
    

    Information

    ID
    636
    Time
    1000ms
    Memory
    256MiB
    Difficulty
    5
    Tags
    # Submissions
    33
    Accepted
    16
    Uploaded By