Submission #1390600
Source Code Expand
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define re(i,a,b) for(int i=(a);i<(b);i++)
#define repd(i,a,b) for(int i=(a);i>=(b);i--)
#define run(v) for(int k=head[v];k;k=e[k].ne)
//#define v e[k].t
#define clr(a) memset(a,0,sizeof(a));
#define il inline
#define sz(a) ((int)a.size())
#define all(a) a.begin(),a.end()
#define mp make_pair
#define pb push_back
#define w1 first
#define w2 second
#define adm(a,b,c) {a=a+b;if(a>=c)a-=c;else if(a<0)a+=c;}
typedef pair<int,int> pa;
typedef long long ll;typedef long double ld;typedef unsigned long long ull;
const int N=2e3+5,M=2e6+5,INF=1e9,mod=1e9+7;
const ll linf=1e18;const double eps=1e-8,pi=acos(-1);
il int gmin(int &a,int b){if(a>b)a=b;}il ll gmin(ll &a,ll b){if(a>b)a=b;}il int gmax(int &a,int b){if(a<b)a=b;}il ll gmax(ll &a,ll b){if(a<b)a=b;}
il void read(ll&x){ll f=1,t=0;char ch=getchar();while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}while(ch>='0'&&ch<='9'){t=t*10+ch-'0';ch=getchar();}x=t*f;}il ll read(ll&x,ll&y){read(x);read(y);}
il void read(int&x){int f=1,t=0;char ch=getchar();while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}while(ch>='0'&&ch<='9'){t=t*10+ch-'0';ch=getchar();}x=t*f;}il int read(int&x,int&y){read(x);read(y);}
il void read(int&a,int&b,int&c){read(a);read(b);read(c);}il void read(ll&a,ll&b,ll&c){read(a);read(b);read(c);}
il int read(){int x;read(x);return x;}
il ll qpow(ll a,ll b,ll p){ll ret=1;for(;b;b>>=1,a=a*a%p)if(b&1)ret=ret*a%p;return ret;}il ll qpow(ll a,ll b){ll ret=1;for(;b;b>>=1,a=a*a%mod)if(b&1)ret=ret*a%mod;return ret;}
il ll qmul(ll a,ll b,ll p){ll ret=0;for(;b;b>>=1,a=(a<<1)%p)if(b&1)adm(ret,a,p);return ret;}il ll qmul(ll a,ll b){ll ret=0;for(;b;b>>=1,a=(a<<1)%mod)if(b&1)adm(ret,a,mod);return ret;}
il void judge(){
freopen("data.in","r",stdin);
freopen("data.out","w",stdout);}
il void gen(){freopen("data.in","w",stdout);}
int n,m,bin[30]={1};
int f[N],g[N],k,ans;
int main(){
read(n,m,k);
f[0]=1;
for(int i=1;;i++){
if(i*(k-1)+1>n+m)break;
int sum=(i-1)*(k-1),sa,sb;
rep(j,0,n)if(f[j])re(a,1,k){
sa=j+a;sb=sum-j+k-a;
if(sa>n||sb>m||sb<0)continue;
if((n-sa)%(k-1)==0&&(m-sb)%(k-1)==0)(ans+=f[j])%=mod;
}
rep(j,0,n)g[j]=0;
rep(j,0,n)re(x,0,k)
(g[j+x]+=f[j])%=mod;
rep(j,0,n)f[j]=g[j];
}
cout<<ans<<endl;
}
Submission Info
Submission Time |
|
Task |
E - Eternal Average |
User |
xjt |
Language |
C++14 (GCC 5.4.1) |
Score |
1600 |
Code Size |
2353 Byte |
Status |
AC |
Exec Time |
87 ms |
Memory |
256 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 |
87 ms |
256 KB |
03.txt |
AC |
1 ms |
256 KB |
04.txt |
AC |
1 ms |
256 KB |
05.txt |
AC |
60 ms |
256 KB |
06.txt |
AC |
1 ms |
256 KB |
07.txt |
AC |
15 ms |
256 KB |
08.txt |
AC |
1 ms |
256 KB |
09.txt |
AC |
39 ms |
256 KB |
10.txt |
AC |
38 ms |
256 KB |
11.txt |
AC |
24 ms |
256 KB |
12.txt |
AC |
20 ms |
256 KB |
13.txt |
AC |
29 ms |
256 KB |
14.txt |
AC |
17 ms |
256 KB |
15.txt |
AC |
26 ms |
256 KB |
16.txt |
AC |
6 ms |
256 KB |
17.txt |
AC |
23 ms |
256 KB |
18.txt |
AC |
8 ms |
256 KB |
19.txt |
AC |
32 ms |
256 KB |
20.txt |
AC |
35 ms |
256 KB |
21.txt |
AC |
1 ms |
256 KB |
22.txt |
AC |
40 ms |
256 KB |
23.txt |
AC |
30 ms |
256 KB |
24.txt |
AC |
26 ms |
256 KB |
s1.txt |
AC |
1 ms |
256 KB |
s2.txt |
AC |
1 ms |
256 KB |
s3.txt |
AC |
1 ms |
256 KB |