Submission #3514717
Source Code Expand
#include<bits/stdc++.h>
#define rint register int
#define rep(i,a,b) for (rint i=(a),_E=(b); i<=_E; ++i)
#define per(i,a,b) for (rint i=(a),_E=(b); i>=_E; --i)
#define REP(i,n) for (rint i=0,_E=(n); i<_E; ++i)
#define pb push_back
#define cmin(x,y) (y<x?x=y:0)
#define cmax(x,y) (y>x?x=y:0)
using namespace std;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef long long ll;
const int N = 10005;
const int mod = 1000000007;
int n, a, b, c, n1, n2, n3, n4, K, res, now;
int fac[N], rev[N];
inline int power(int x, int p) {
int res = 1;
while (p) {
if (p & 1) res = 1ll * x * res % mod;
x = 1ll * x * x % mod; p >>= 1;
}
return res;
}
inline int C(int n, int m) {
if (m < 0 || m > n) return 0;
return 1ll * fac[n] * rev[m] % mod * rev[n-m] % mod;
}
//将n划分为m份,可以为空
inline int calc(int n, int m) {
if (!n && !m) return 1;
return C(n + m - 1, m - 1);
}
int main() {
scanf("%d%d%d%d", &n, &a, &b, &c);
if (b & 1) return puts("0"), 0;
fac[0] = rev[0] = 1;
rep (i, 1, 10000) {
fac[i] = 1ll * i * fac[i-1] % mod;
rev[i] = power(fac[i], mod - 2);
}
rep (x, 0, min(a, c)) rep (y, 0, (c - x) / 3) {
n1 = b / 2, n2 = y, n3 = a - x, n4 = x, K = c - x - 3 * y;
if (n1 < 0 || n2 < 0 || n3 < 0 || n4 < 0 || K < 0) continue;
now = 1ll * fac[n1 + n2 + n3 + n4] * calc(K, n1) % mod;
now = 1ll * now * rev[n1] % mod * rev[n2] % mod;
now = 1ll * now * rev[n3] % mod * rev[n4] % mod;
res = (res + now) % mod;
}
printf("%d\n", res);
return 0;
}
Submission Info
Submission Time |
|
Task |
J - 123 Pairs |
User |
Cyanic |
Language |
C++14 (GCC 5.4.1) |
Score |
1500 |
Code Size |
1548 Byte |
Status |
AC |
Exec Time |
26 ms |
Memory |
384 KB |
Compile Error
./Main.cpp: In function ‘int main()’:
./Main.cpp:40:35: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d%d%d%d", &n, &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 |
14 ms |
256 KB |
001.txt |
AC |
3 ms |
384 KB |
002.txt |
AC |
3 ms |
384 KB |
003.txt |
AC |
3 ms |
256 KB |
004.txt |
AC |
3 ms |
384 KB |
005.txt |
AC |
3 ms |
384 KB |
006.txt |
AC |
3 ms |
256 KB |
007.txt |
AC |
3 ms |
256 KB |
008.txt |
AC |
3 ms |
384 KB |
009.txt |
AC |
3 ms |
384 KB |
010.txt |
AC |
3 ms |
384 KB |
011.txt |
AC |
3 ms |
256 KB |
012.txt |
AC |
3 ms |
384 KB |
013.txt |
AC |
3 ms |
384 KB |
014.txt |
AC |
3 ms |
384 KB |
015.txt |
AC |
21 ms |
384 KB |
016.txt |
AC |
4 ms |
384 KB |
017.txt |
AC |
8 ms |
384 KB |
018.txt |
AC |
4 ms |
384 KB |
019.txt |
AC |
9 ms |
256 KB |
020.txt |
AC |
5 ms |
256 KB |
021.txt |
AC |
18 ms |
384 KB |
022.txt |
AC |
4 ms |
384 KB |
023.txt |
AC |
6 ms |
384 KB |
024.txt |
AC |
19 ms |
384 KB |
025.txt |
AC |
5 ms |
384 KB |
026.txt |
AC |
12 ms |
384 KB |
027.txt |
AC |
18 ms |
384 KB |
028.txt |
AC |
8 ms |
384 KB |
029.txt |
AC |
10 ms |
384 KB |
030.txt |
AC |
18 ms |
256 KB |
031.txt |
AC |
19 ms |
384 KB |
032.txt |
AC |
4 ms |
256 KB |
033.txt |
AC |
1 ms |
256 KB |
034.txt |
AC |
9 ms |
384 KB |
035.txt |
AC |
11 ms |
256 KB |
036.txt |
AC |
4 ms |
384 KB |
037.txt |
AC |
3 ms |
384 KB |
038.txt |
AC |
26 ms |
384 KB |
039.txt |
AC |
1 ms |
256 KB |
040.txt |
AC |
1 ms |
256 KB |
041.txt |
AC |
7 ms |
384 KB |
042.txt |
AC |
3 ms |
384 KB |
043.txt |
AC |
3 ms |
256 KB |
044.txt |
AC |
3 ms |
384 KB |
045.txt |
AC |
3 ms |
256 KB |
046.txt |
AC |
3 ms |
256 KB |
047.txt |
AC |
3 ms |
256 KB |
048.txt |
AC |
3 ms |
256 KB |
049.txt |
AC |
3 ms |
384 KB |
example0.txt |
AC |
3 ms |
384 KB |
example1.txt |
AC |
3 ms |
384 KB |