Submission #1753278
Source Code Expand
#include"bits/stdc++.h"
#define PB push_back
#define PF push_front
#define LB lower_bound
#define UB upper_bound
#define fr(x) freopen(x,"r",stdin)
#define fw(x) freopen(x,"w",stdout)
#define iout(x) printf("%d\n",x)
#define lout(x) printf("%lld\n",x)
#define REP(x,l,u) for(ll x = (l);x<=(u);x++)
#define RREP(x,l,u) for(ll x = (l);x>=(u);x--)
#define mst(x,a) memset(x,a,sizeof(x))
#define PII pair<int,int>
#define PLL pair<ll,ll>
#define MP make_pair
#define se second
#define fi first
#define dbg(x) cout<<#x<<" = "<<(x)<<endl;
#define sz(x) ((int)x.size())
#define cl(x) x.clear()
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ld;
using namespace std;
const int maxn = 100010;
const int mod = 1e9+7;
const int MAX = 1000000010;
const double eps = 1e-6;
const double PI = acos(-1);
template<typename T> inline void read(T &x){
x=0;T f=1;char ch;do{ch=getchar();if(ch=='-')f=-1;}while(ch<'0'||ch>'9');do x=x*10+ch-'0',ch=getchar();while(ch<='9'&&ch>='0');x*=f;
}
template<typename A,typename B> inline void read(A&x,B&y){read(x);read(y);}
template<typename A,typename B,typename C> inline void read(A&x,B&y,C&z){read(x);read(y);read(z);}
template<typename A,typename B,typename C,typename D> inline void read(A&x,B&y,C&z,D&w){read(x);read(y);read(z);read(w);}
template<typename A,typename B> inline A fexp(A x,B p){A ans=1;for(;p;p>>=1,x=1LL*x*x%mod)if(p&1)ans=1LL*ans*x%mod;return ans;}
template<typename A,typename B> inline A fexp(A x,B p,A mo){A ans=1;for(;p;p>>=1,x=1LL*x*x%mo)if(p&1)ans=1LL*ans*x%mo;return ans;}
int n,m,k,ans;
int dp[4010][2010];
void Work(){
dp[1][1]++;dp[1][k]=(mod-1);
REP(i,1,n+m)
REP(j,1,n)if(dp[i][j]=(dp[i][j]+dp[i][j-1])%mod){
dp[i+1][j]=(dp[i+1][j]+dp[i][j])%mod;
dp[i+1][min(n+1,(int)j+k)]=(dp[i+1][min(n+1,(int)j+k)]+mod-dp[i][j])%mod;
if((n-j)%(k-1)==0&&(k-1)*i-j<m&&(j+m-1)%(k-1)==0)ans=(ans+dp[i][j])%mod;
}
iout(ans);
}
void Init(){
read(n,m,k);
}
int main(){
Init();
Work();
return 0;
}
Submission Info
Submission Time |
|
Task |
E - Eternal Average |
User |
yanQval |
Language |
C++14 (GCC 5.4.1) |
Score |
1600 |
Code Size |
2079 Byte |
Status |
AC |
Exec Time |
170 ms |
Memory |
31616 KB |
Judge Result
Set Name |
Sample |
All |
Score / Max Score |
0 / 0 |
1600 / 1600 |
Status |
|
|
Set Name |
Test Cases |
Sample |
s1.txt, s2.txt, s3.txt |
All |
01.txt, 02.txt, 03.txt, 04.txt, 05.txt, 06.txt, 07.txt, 08.txt, 09.txt, 10.txt, 11.txt, 12.txt, 13.txt, 14.txt, 15.txt, 16.txt, 17.txt, 18.txt, 19.txt, 20.txt, 21.txt, 22.txt, 23.txt, 24.txt, s1.txt, s2.txt, s3.txt |
Case Name |
Status |
Exec Time |
Memory |
01.txt |
AC |
1 ms |
256 KB |
02.txt |
AC |
170 ms |
31616 KB |
03.txt |
AC |
1 ms |
256 KB |
04.txt |
AC |
1 ms |
256 KB |
05.txt |
AC |
152 ms |
31616 KB |
06.txt |
AC |
5 ms |
15616 KB |
07.txt |
AC |
71 ms |
16640 KB |
08.txt |
AC |
4 ms |
5504 KB |
09.txt |
AC |
151 ms |
31616 KB |
10.txt |
AC |
153 ms |
31616 KB |
11.txt |
AC |
149 ms |
31616 KB |
12.txt |
AC |
149 ms |
31616 KB |
13.txt |
AC |
127 ms |
30976 KB |
14.txt |
AC |
84 ms |
22784 KB |
15.txt |
AC |
113 ms |
28928 KB |
16.txt |
AC |
54 ms |
16640 KB |
17.txt |
AC |
126 ms |
28928 KB |
18.txt |
AC |
26 ms |
20224 KB |
19.txt |
AC |
58 ms |
18688 KB |
20.txt |
AC |
126 ms |
28928 KB |
21.txt |
AC |
1 ms |
256 KB |
22.txt |
AC |
149 ms |
31616 KB |
23.txt |
AC |
122 ms |
28928 KB |
24.txt |
AC |
111 ms |
28928 KB |
s1.txt |
AC |
1 ms |
256 KB |
s2.txt |
AC |
1 ms |
256 KB |
s3.txt |
AC |
3 ms |
3456 KB |