Submission #1000862
Source Code Expand
#include <bits/stdc++.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define RI(X) scanf("%d", &(X))
#define RII(X, Y) scanf("%d%d", &(X), &(Y))
#define RIII(X, Y, Z) scanf("%d%d%d", &(X), &(Y), &(Z))
#define DRI(X) int (X); scanf("%d", &X)
#define DRII(X, Y) int X, Y; scanf("%d%d", &X, &Y)
#define DRIII(X, Y, Z) int X, Y, Z; scanf("%d%d%d", &X, &Y, &Z)
#define RS(X) scanf("%s", (X))
#define CASET int ___T, case_n = 1; scanf("%d ", &___T); while (___T-- > 0)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define PII pair<int,int>
#define VI vector<int>
#define VPII vector<pair<int,int> >
#define PLL pair<long long,long long>
#define VPLL vector<pair<long long,long long> >
#define F first
#define S second
typedef long long LL;
using namespace std;
const int MOD = 1e9+7;
const int SIZE = 1e6+10;
LL fac[SIZE],inv[SIZE];
LL mypow(LL x,LL y){
LL res=1;
while(y){
if(y&1)res=res*x%MOD;
y>>=1;
x=x*x%MOD;
}
return res;
}
LL CC(int x,int y){
if(y<0||y>x)return 0;
return fac[x]*inv[y]%MOD*inv[x-y]%MOD;
}
void build(){
assert(MOD>=SIZE);
fac[0]=1;
REPP(i,1,SIZE)fac[i]=fac[i-1]*i%MOD;
inv[SIZE-1]=mypow(fac[SIZE-1],MOD-2);
for(int i=SIZE-2;i>=0;i--)inv[i]=inv[i+1]*(i+1)%MOD;
}
LL dp[5001][5001];
void ADD(LL& x,LL v){x=(x+v)%MOD;}
int main(){
build();
DRI(N);
DRIII(A,B,C);
if(B%2)return 0*puts("0");
MS1(dp);
LL base=CC(A+B/2,A),an=0;
if(B){
REP(i,C+1)REP(j,C-i+1){
if((C-i-j)%3)continue;
ADD(an,CC(A,i)*CC(A+B/2+(C-i-j)/3,(C-i-j)/3)%MOD*CC(B/2+j-1,j));
}
}
else{
REP(i,C+1){
int j=0;
if((C-i-j)%3)continue;
ADD(an,CC(A,i)*CC(A+B/2+(C-i-j)/3,(C-i-j)/3));
}
}
cout<<an*base%MOD<<endl;
return 0;
}
Submission Info
Submission Time
2016-11-28 13:26:14+0900
Task
J - 123 Pairs
User
dreamoon
Language
C++14 (GCC 5.4.1)
Score
1500
Code Size
2120 Byte
Status
AC
Exec Time
301 ms
Memory
211328 KB
Compile Error
./Main.cpp: In function ‘int main()’:
./Main.cpp:55:11: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
DRI(N);
^
./Main.cpp:56:17: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
DRIII(A,B,C);
^
Judge Result
Set Name
Sample
All
Score / Max Score
0 / 0
1500 / 1500
Status
Set Name
Test Cases
Sample
example0.txt, example1.txt
All
000.txt, 001.txt, 002.txt, 003.txt, 004.txt, 005.txt, 006.txt, 007.txt, 008.txt, 009.txt, 010.txt, 011.txt, 012.txt, 013.txt, 014.txt, 015.txt, 016.txt, 017.txt, 018.txt, 019.txt, 020.txt, 021.txt, 022.txt, 023.txt, 024.txt, 025.txt, 026.txt, 027.txt, 028.txt, 029.txt, 030.txt, 031.txt, 032.txt, 033.txt, 034.txt, 035.txt, 036.txt, 037.txt, 038.txt, 039.txt, 040.txt, 041.txt, 042.txt, 043.txt, 044.txt, 045.txt, 046.txt, 047.txt, 048.txt, 049.txt, example0.txt, example1.txt
Case Name
Status
Exec Time
Memory
000.txt
AC
225 ms
211200 KB
001.txt
AC
301 ms
211200 KB
002.txt
AC
213 ms
211200 KB
003.txt
AC
212 ms
211200 KB
004.txt
AC
297 ms
211200 KB
005.txt
AC
212 ms
211200 KB
006.txt
AC
213 ms
211200 KB
007.txt
AC
213 ms
211200 KB
008.txt
AC
212 ms
211200 KB
009.txt
AC
214 ms
211200 KB
010.txt
AC
211 ms
211200 KB
011.txt
AC
213 ms
211200 KB
012.txt
AC
213 ms
211200 KB
013.txt
AC
212 ms
211200 KB
014.txt
AC
214 ms
211200 KB
015.txt
AC
239 ms
211328 KB
016.txt
AC
218 ms
211200 KB
017.txt
AC
218 ms
211200 KB
018.txt
AC
214 ms
211200 KB
019.txt
AC
227 ms
211200 KB
020.txt
AC
214 ms
211200 KB
021.txt
AC
242 ms
211200 KB
022.txt
AC
214 ms
211200 KB
023.txt
AC
216 ms
211200 KB
024.txt
AC
250 ms
211328 KB
025.txt
AC
216 ms
211200 KB
026.txt
AC
223 ms
211200 KB
027.txt
AC
230 ms
211200 KB
028.txt
AC
218 ms
211200 KB
029.txt
AC
220 ms
211200 KB
030.txt
AC
278 ms
211328 KB
031.txt
AC
235 ms
211200 KB
032.txt
AC
215 ms
211200 KB
033.txt
AC
29 ms
15872 KB
034.txt
AC
245 ms
211200 KB
035.txt
AC
221 ms
211200 KB
036.txt
AC
216 ms
211200 KB
037.txt
AC
214 ms
211328 KB
038.txt
AC
266 ms
211200 KB
039.txt
AC
29 ms
15872 KB
040.txt
AC
29 ms
15872 KB
041.txt
AC
265 ms
211200 KB
042.txt
AC
213 ms
211200 KB
043.txt
AC
213 ms
211200 KB
044.txt
AC
213 ms
211200 KB
045.txt
AC
213 ms
211200 KB
046.txt
AC
213 ms
211200 KB
047.txt
AC
212 ms
211200 KB
048.txt
AC
213 ms
211200 KB
049.txt
AC
212 ms
211200 KB
example0.txt
AC
213 ms
211200 KB
example1.txt
AC
213 ms
211200 KB