Submission #1076809


Source Code Expand

#define DEB
#include<bits/stdc++.h>
#define REP(i,m) for(int i=0;i<(m);++i)
#define REPN(i,m,in) for(int i=(in);i<(m);++i)
#define ALL(t) (t).begin(),(t).end()
#define CLR(a) memset((a),0,sizeof(a))
#define pb push_back
#define mp make_pair
#define fr first
#define sc second

using namespace std;


#ifdef DEB
#define dump(x)  cerr << #x << " = " << (x) << endl
#define prl cerr<<"called:"<< __LINE__<<endl
#define dumpR(x) cerr<<"\x1b[31m"<<#x<<" = " <<(x)<<"\x1b[39m"<<endl
#define dumpY(x) cerr<<"\x1b[33m"<<#x<<" = " <<(x)<<"\x1b[39m"<<endl
#define dumpG(x) cerr<<"\x1b[32m"<<#x<<" = " <<(x)<<"\x1b[39m"<<endl
template<class T> void debug(T a,T b){ for(;a!=b;++a) cerr<<*a<<' ';cerr<<endl;}
#else
#define dump(x) ;
#define dumpR(x) ;
#define dumpY(x) ;
#define dumpG(x) ;
#define prl ;
template<class T> void debug(T a,T b){ ;}
#endif

template<class T> void chmin(T& a,const T& b) { if(a>b) a=b; }
template<class T> void chmax(T& a,const T& b) { if(a<b) a=b; }

typedef long long int lint;
typedef pair<int,int> pi;

namespace std{
  template<class S,class T>
  ostream &operator <<(ostream& out,const pair<S,T>& a){
    out<<'('<<a.fr<<','<<a.sc<<')';
    return out;
  }
}

//const int INF=5e8;
int dp[2005][2005];
int n,m,K;
const int mod=1000000007;
void chadd(int& a,int b){
  a+=b;
  if(a>=mod) a-=mod;
}
int rec(int zero,int one){
  if(zero<0 || one<0) return 0;
  if(zero+one==1) return 1;
  if(zero==0 || one==0) return 0;
  if(zero+one==K) return 1;
  int& res=dp[zero][one];
  if(~res) return res;
  res=0;

  REP(i,K){//n.o. zero
    chadd(res,rec(zero-i,one-(K-1-i)));
  }
  return res;
}
int main(){
  cin>>n>>m>>K;
  memset(dp,-1,sizeof(dp));
  int res=0;
  for(int i=n;i>0;i-=K-1) for(int j=m;j>0;j-=K-1){
    chadd(res,rec(i,j));
  }
  cout<<res<<endl;
  return 0;
}



Submission Info

Submission Time
Task E - Eternal Average
User hogloid
Language C++14 (GCC 5.4.1)
Score 1600
Code Size 1872 Byte
Status AC
Exec Time 143 ms
Memory 16128 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 1600 / 1600
Status
AC × 3
AC × 27
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 22 ms 16000 KB
02.txt AC 143 ms 16128 KB
03.txt AC 22 ms 16000 KB
04.txt AC 22 ms 16000 KB
05.txt AC 108 ms 16128 KB
06.txt AC 22 ms 16000 KB
07.txt AC 22 ms 16000 KB
08.txt AC 23 ms 16000 KB
09.txt AC 85 ms 16000 KB
10.txt AC 81 ms 16000 KB
11.txt AC 29 ms 16000 KB
12.txt AC 22 ms 16000 KB
13.txt AC 67 ms 16000 KB
14.txt AC 41 ms 16000 KB
15.txt AC 63 ms 16000 KB
16.txt AC 22 ms 16000 KB
17.txt AC 39 ms 16000 KB
18.txt AC 33 ms 16000 KB
19.txt AC 28 ms 16128 KB
20.txt AC 72 ms 16000 KB
21.txt AC 22 ms 16000 KB
22.txt AC 83 ms 16000 KB
23.txt AC 67 ms 16000 KB
24.txt AC 62 ms 16000 KB
s1.txt AC 22 ms 16000 KB
s2.txt AC 22 ms 16000 KB
s3.txt AC 22 ms 16000 KB