Submission #1161856
Source Code Expand
#include <bits/stdc++.h> using namespace std; using ll = long long; ll mod = 1e9+7; ll dp[500][500]; ll A[500]; ll B[500]; ll powdp[500][500]; ll modPow(ll a, ll b) { if (powdp[a][b] > -1) return powdp[a][b]; ll ret = a; if (b == 0) ret = 1; if (b > 1) { for (ll i = 0; i < b - 1; ++i) { if (powdp[a][i+2] > -1) {ret = powdp[a][i+2]; continue;} ret *= a; ret %= mod; powdp[a][i+2] = ret; } } powdp[a][b] = ret; return ret; } int main() { ll N, C; cin >> N >> C; for (ll i = 0; i < N; ++i) cin >> A[i]; for (ll i = 0; i < N; ++i) cin >> B[i]; memset(dp, 0, sizeof(dp)); memset(powdp, -1, sizeof(powdp)); dp[0][0] = 1; for (ll a = 0; a <= N; ++a) { for (ll b = 0; b <= C; ++b) { ll sum = 0; for (ll c = 0; c < b; ++c) sum += dp[a][c] * modPow(A[a], (b - c)); sum %= mod; dp[a+1][b] = dp[a][b] + sum; dp[a+1][b] %= mod; } } cout << dp[N][C] % mod << endl; }
Submission Info
Submission Time | |
---|---|
Task | E - Children and Candies |
User | Veronica |
Language | C++14 (GCC 5.4.1) |
Score | 0 |
Code Size | 955 Byte |
Status | WA |
Exec Time | 59 ms |
Memory | 4096 KB |
Judge Result
Set Name | Sample | Subtask | All | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 0 / 400 | 0 / 400 | ||||||||||||
Status |
|
|
|
Set Name | Test Cases |
---|---|
Sample | 0_000.txt, 0_001.txt, 0_002.txt, 0_003.txt, 0_004.txt |
Subtask | 0_001, 0_003, 1_005.txt, 1_006.txt, 1_007.txt, 1_008.txt, 1_009.txt, 1_010.txt, 1_011.txt, 1_012.txt, 1_013.txt, 1_014.txt, 1_015.txt, 1_016.txt |
All | 0_000.txt, 0_001.txt, 0_002.txt, 0_003.txt, 0_004.txt, 1_005.txt, 1_006.txt, 1_007.txt, 1_008.txt, 1_009.txt, 1_010.txt, 1_011.txt, 1_012.txt, 1_013.txt, 1_014.txt, 1_015.txt, 1_016.txt, 2_017.txt, 2_018.txt, 2_019.txt, 2_020.txt, 2_021.txt, 2_022.txt, 2_023.txt, 2_024.txt, 2_025.txt, 2_026.txt, 2_027.txt, 2_028.txt, 2_029.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
0_000.txt | WA | 3 ms | 4096 KB |
0_001.txt | AC | 3 ms | 4096 KB |
0_002.txt | WA | 3 ms | 4096 KB |
0_003.txt | AC | 3 ms | 4096 KB |
0_004.txt | WA | 3 ms | 4096 KB |
1_005.txt | AC | 3 ms | 4096 KB |
1_006.txt | AC | 3 ms | 4096 KB |
1_007.txt | AC | 3 ms | 4096 KB |
1_008.txt | AC | 3 ms | 4096 KB |
1_009.txt | AC | 3 ms | 4096 KB |
1_010.txt | AC | 3 ms | 4096 KB |
1_011.txt | AC | 3 ms | 4096 KB |
1_012.txt | AC | 3 ms | 4096 KB |
1_013.txt | AC | 3 ms | 4096 KB |
1_014.txt | AC | 45 ms | 4096 KB |
1_015.txt | WA | 45 ms | 4096 KB |
1_016.txt | WA | 59 ms | 4096 KB |
2_017.txt | WA | 3 ms | 4096 KB |
2_018.txt | WA | 3 ms | 4096 KB |
2_019.txt | WA | 3 ms | 4096 KB |
2_020.txt | WA | 3 ms | 4096 KB |
2_021.txt | WA | 3 ms | 4096 KB |
2_022.txt | WA | 3 ms | 4096 KB |
2_023.txt | WA | 45 ms | 4096 KB |
2_024.txt | WA | 58 ms | 4096 KB |
2_025.txt | WA | 13 ms | 4096 KB |
2_026.txt | WA | 4 ms | 4096 KB |
2_027.txt | WA | 47 ms | 4096 KB |
2_028.txt | WA | 4 ms | 4096 KB |
2_029.txt | WA | 3 ms | 4096 KB |