Submission #1150386
Source Code Expand
#include <set> #include <map> #include <cmath> #include <ctime> #include <deque> #include <queue> #include <stack> #include <vector> #include <bitset> #include <string> #include <cstdio> #include <cassert> #include <cstdlib> #include <cstring> #include <iomanip> #include <iostream> #include <algorithm> #define mk make_pair #define pb push_back #define fi first #define se second #define REP(i, x, y) for(int i = (int)x; i <= (int)y; i ++) #define FOR(i, x, y) for(int i = (int)x; i < (int)y; i ++) #define PER(i, x, y) for(int i = (int)x; i >= (int)y; i --) #define trace(x) cerr << #x << " " << x << endl; #define dprintf(...) fprintf(stderr, __VA__ARGS__) #define dln() fprintf(stderr, "\n") using namespace std; typedef long long LL; typedef long double db; typedef pair<int,int> PII; typedef vector<int> VI; typedef vector<PII> VPI; const int N = 100005; const int P = 1e9 + 7; const int inf = 1e9; const LL Inf = 1e15; inline int IN(){ char ch = getchar(); int x = 0, f = 0; while(ch < '0' || ch > '9') ch = getchar(), f = (ch == '-'); while(ch >= '0' && ch <= '9'){ x = (x << 1) + (x << 3) + ch - 48; ch = getchar(); } return f ? (-x) : x; } inline int Pow(int x, int y, int p){ int an = 1; for(; y; y >>= 1, x = (LL)x * x % p) if(y & 1) an = (LL)an * x % p; return an; } template<typename T> inline void chkmin(T &a, const T &b) {if(a > b) a = b;} template<typename T> inline void chkmax(T &a, const T &b) {if(a < b) a = b;} int n, A, B, C; int fac[10005], ifac[10005]; int Comb(int x, int y){ if(y < 0 || x < y) return 0; return (LL)fac[x] * ifac[y] % P * ifac[x - y] % P; } int AA = 0; int ask(int w){ //\sum{a[i]} = B / 2 //\sum{i * a[i]} = w //sum of \prod{a[i]!} if(B == 0) return w == 0; return (LL)AA * Comb(B / 2 + w - 1, B / 2 - 1) % P; } int main(){ cin >> n >> A >> B >> C; if(B & 1){ puts("0"); return 0; } ifac[0] = 1; REP(i, 1, 10000) ifac[i] = (LL)ifac[i - 1] * Pow(i, P - 2, P) % P; REP(i, 0, 10000) fac[i] = Pow(ifac[i], P - 2, P); AA = ifac[B / 2]; int ans = 0; REP(a, 0, A) for(int b = 0; 3 * b <= C; b ++){ int ww = C - A + a - 3 * b; if(ww < 0) continue; int cf = (LL)fac[A + b + B / 2] * ifac[a] % P * ifac[A - a] % P * ifac[b] % P; cf = (LL)cf * ask(ww) % P; ans = (ans + cf) % P; } printf("%d\n", ans); return 0; }
Submission Info
Submission Time | |
---|---|
Task | J - 123 Pairs |
User | syc19999 |
Language | C++14 (GCC 5.4.1) |
Score | 1500 |
Code Size | 2436 Byte |
Status | AC |
Exec Time | 24 ms |
Memory | 384 KB |
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 | 384 KB |
001.txt | AC | 4 ms | 256 KB |
002.txt | AC | 4 ms | 256 KB |
003.txt | AC | 4 ms | 256 KB |
004.txt | AC | 4 ms | 256 KB |
005.txt | AC | 4 ms | 256 KB |
006.txt | AC | 4 ms | 384 KB |
007.txt | AC | 4 ms | 256 KB |
008.txt | AC | 4 ms | 384 KB |
009.txt | AC | 4 ms | 256 KB |
010.txt | AC | 4 ms | 384 KB |
011.txt | AC | 4 ms | 256 KB |
012.txt | AC | 4 ms | 384 KB |
013.txt | AC | 4 ms | 256 KB |
014.txt | AC | 4 ms | 256 KB |
015.txt | AC | 20 ms | 384 KB |
016.txt | AC | 5 ms | 256 KB |
017.txt | AC | 9 ms | 384 KB |
018.txt | AC | 5 ms | 256 KB |
019.txt | AC | 9 ms | 256 KB |
020.txt | AC | 6 ms | 256 KB |
021.txt | AC | 18 ms | 256 KB |
022.txt | AC | 6 ms | 256 KB |
023.txt | AC | 8 ms | 256 KB |
024.txt | AC | 18 ms | 256 KB |
025.txt | AC | 7 ms | 384 KB |
026.txt | AC | 13 ms | 384 KB |
027.txt | AC | 17 ms | 256 KB |
028.txt | AC | 9 ms | 256 KB |
029.txt | AC | 11 ms | 256 KB |
030.txt | AC | 17 ms | 256 KB |
031.txt | AC | 18 ms | 256 KB |
032.txt | AC | 6 ms | 384 KB |
033.txt | AC | 1 ms | 256 KB |
034.txt | AC | 9 ms | 256 KB |
035.txt | AC | 12 ms | 384 KB |
036.txt | AC | 6 ms | 256 KB |
037.txt | AC | 4 ms | 256 KB |
038.txt | AC | 24 ms | 256 KB |
039.txt | AC | 1 ms | 256 KB |
040.txt | AC | 1 ms | 256 KB |
041.txt | AC | 8 ms | 256 KB |
042.txt | AC | 5 ms | 256 KB |
043.txt | AC | 4 ms | 256 KB |
044.txt | AC | 4 ms | 384 KB |
045.txt | AC | 4 ms | 256 KB |
046.txt | AC | 4 ms | 384 KB |
047.txt | AC | 4 ms | 384 KB |
048.txt | AC | 4 ms | 384 KB |
049.txt | AC | 4 ms | 256 KB |
example0.txt | AC | 4 ms | 384 KB |
example1.txt | AC | 5 ms | 256 KB |