Submission #1963760
Source Code Expand
#include <iostream> using namespace std; long long N, A, B, C, sum1[5009], sum2[5009][5009], ans, mod = 1000000007; long long fact[5009], inv[5009], factinv[5009]; void init() { fact[0] = 1; for (int i = 1; i <= 5000; i++) fact[i] = (fact[i - 1] * i) % mod; inv[1] = 1; for (int i = 2; i <= 5000; i++)inv[i] = (mod - (1LL * (mod / i)*inv[mod%i]) % mod) % mod; factinv[0] = 1; for (int i = 1; i <= 5000; i++)factinv[i] = (factinv[i - 1] * inv[i]) % mod; } long long ncr(long long n, long long r) { if (n < 0 || r < 0 || n < r) return 0; return (((fact[n] * factinv[n - r]) % mod)*factinv[r]) % mod; } int main() { init(); cin >> N >> A >> B >> C; if (B % 2 == 1) { cout << "0" << endl; return 0; } for (int i = 0; i <= B / 2; i++) { for (int j = 0; j <= C; j++) { long long ret = factinv[i] * factinv[B / 2 - i]; ret *= ncr(j + (i - 1), (i - 1)); ret %= mod; sum1[j] += ret; sum1[j] %= mod; } } for (int i = 0; i <= C; i++) { for (int j = 0; j <= C; j += 3) { if (i + j > C || i > A) continue; long long P1 = A - i, P2 = i, P3 = j / 3; long long ret = factinv[P1] * factinv[P2]; ret %= mod; ret *= factinv[P3]; ret %= mod; sum2[P1 + P2 + P3][i + j] += ret; sum2[P1 + P2 + P3][j] %= mod; } } for (int i = 0; i <= C; i++) { for (int j = 0; j <= N; j++) { ans += ((sum1[i] * sum2[j + A + i][C - i]) % mod)*fact[j]; ans %= mod; } } cout << ans << endl; return 0; }
Submission Info
Submission Time | |
---|---|
Task | J - 123 Pairs |
User | E869120 |
Language | C++14 (GCC 5.4.1) |
Score | 0 |
Code Size | 1463 Byte |
Status | RE |
Exec Time | 268 ms |
Memory | 64128 KB |
Judge Result
Set Name | Sample | All | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 0 / 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 | RE | 216 ms | 24960 KB |
001.txt | RE | 125 ms | 64128 KB |
002.txt | RE | 101 ms | 384 KB |
003.txt | RE | 99 ms | 384 KB |
004.txt | RE | 123 ms | 64128 KB |
005.txt | WA | 4 ms | 384 KB |
006.txt | RE | 98 ms | 384 KB |
007.txt | RE | 127 ms | 64128 KB |
008.txt | WA | 5 ms | 384 KB |
009.txt | RE | 98 ms | 384 KB |
010.txt | RE | 102 ms | 384 KB |
011.txt | WA | 2 ms | 384 KB |
012.txt | RE | 127 ms | 64128 KB |
013.txt | WA | 3 ms | 2432 KB |
014.txt | WA | 7 ms | 4480 KB |
015.txt | RE | 204 ms | 37248 KB |
016.txt | WA | 58 ms | 16768 KB |
017.txt | RE | 207 ms | 18816 KB |
018.txt | WA | 30 ms | 8576 KB |
019.txt | RE | 268 ms | 27008 KB |
020.txt | RE | 113 ms | 10624 KB |
021.txt | RE | 229 ms | 39296 KB |
022.txt | RE | 135 ms | 10624 KB |
023.txt | RE | 138 ms | 12672 KB |
024.txt | RE | 227 ms | 43392 KB |
025.txt | RE | 121 ms | 12672 KB |
026.txt | RE | 190 ms | 22912 KB |
027.txt | RE | 193 ms | 27008 KB |
028.txt | RE | 147 ms | 16768 KB |
029.txt | RE | 186 ms | 20864 KB |
030.txt | RE | 175 ms | 57728 KB |
031.txt | RE | 228 ms | 35200 KB |
032.txt | RE | 135 ms | 10624 KB |
033.txt | AC | 2 ms | 384 KB |
034.txt | RE | 252 ms | 41344 KB |
035.txt | RE | 148 ms | 20864 KB |
036.txt | WA | 85 ms | 10624 KB |
037.txt | WA | 2 ms | 2432 KB |
038.txt | RE | 191 ms | 49536 KB |
039.txt | AC | 2 ms | 384 KB |
040.txt | AC | 2 ms | 384 KB |
041.txt | RE | 224 ms | 53632 KB |
042.txt | RE | 116 ms | 4480 KB |
043.txt | AC | 2 ms | 384 KB |
044.txt | AC | 2 ms | 384 KB |
045.txt | WA | 2 ms | 384 KB |
046.txt | WA | 2 ms | 384 KB |
047.txt | WA | 2 ms | 384 KB |
048.txt | WA | 2 ms | 384 KB |
049.txt | WA | 2 ms | 384 KB |
example0.txt | WA | 2 ms | 384 KB |
example1.txt | WA | 9 ms | 6528 KB |