1 solutions

  • 0
    @ 2026-7-29 10:54:05
    #include<bits/stdc++.h>
    using namespace std;
    #define MOD         1000000007
    #define speMOD      2933256077ll
    #define int         long long
    #define pii         pair<int,int>
    #define all(v)      v.begin(),v.end()
    #define pb          push_back
    #define REP(i,b,e)  for(int i=(b);i<(int)(e);++i)
    #define over(x)     {cout<<(x)<<endl;return;}
    #define lowbit(x)   ((x)&(-(x)))
    #define cntbit(x)   __builtin_popcount(x)
    #define deal(v)     sort(all(v));v.erase(unique(v.begin(),v.end()),v.end())
    #define lbound(v,x) lower_bound(all(v),x)-v.begin()
    mt19937 sd(random_device{}());
    int n,m,k;
    int f[4005][2005];
    void Main() {
    	cin>>m>>n>>k;
    	REP(i,1,k)f[k][i]=1;
    	for(int i=k;i<=n+m;){
    		REP(j,0,n+1)if(f[i][j]){
    			f[i][j]%=MOD;
    			int mn=max(0ll,i-j+k-1-m);
    			f[i+k-1][j+mn]+=f[i][j];
    			f[i+k-1][j+k]-=f[i][j];
    		}
    		i+=k-1;
    		REP(j,1,n+1)f[i][j]+=f[i][j-1];
    	}
    	int ans=0;
    	REP(i,1,n+1)REP(j,0,m+1)if((n-i)%(k-1)==0)(ans+=f[i+j][i])%=MOD;
    	over(ans)
    }
    void TC() {
        int tc=1;
    	while(tc--){
    		Main();
    		cout.flush();
    	}
    }
    signed main() {freopen("number.in","r",stdin);freopen("number.out","w",stdout);
    	return cin.tie(0),cout.tie(0),ios::sync_with_stdio(0),TC(),0;
    }
    /*
    1. CLEAR the arrays (ESPECIALLY multitests)
    2. DELETE useless output
     */
    
    • 1

    Information

    ID
    3071
    Time
    1000ms
    Memory
    512MiB
    Difficulty
    10
    Tags
    (None)
    # Submissions
    1
    Accepted
    1
    Uploaded By