Submission #1226996
Source Code Expand
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <iostream>
using namespace std;
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
typedef long long ll;
const int MOD = 1000000007;
struct K {
int lb;
int ub;
};
ll mypow(ll x, ll n) {
if (n == 0) return 1;
if (n & 1) return mypow(x * x % MOD, n / 2) * x % MOD;
return mypow(x * x % MOD, n / 2);
}
int cmb[410][410];
int n;
K vs[410];
ll memo[410][410];
ll solve(int pos, int rest) {
ll& res = memo[pos][rest];
if(res < 0) {
if(pos == n-1) {
res = mypow(vs[pos].lb, rest);
} else {
res = 0;
for(int i = 0; i <= rest; ++i) {
ll cur = mypow(vs[pos].lb, i);
res = (res + cur * solve(pos+1, rest-i)) % MOD;
}
}
// cerr << "solve(" << pos << ", " << rest << ") = " << res << endl;
}
return res;
}
int main(void) {
REP(i, 405) {
cmb[i][0] = 1;
for(int j = 1; j < 405; ++j) {
cmb[i][j] = (cmb[i-1][j] + cmb[i-1][j-1]) % MOD;
}
}
int nCandy;
scanf("%d%d", &n, &nCandy);
REP(i, n) {
scanf("%d", &vs[i].lb);
}
REP(i, n) {
scanf("%d", &vs[i].ub);
}
REP(i, n) {
// cerr << vs[i].lb << " " << vs[i].ub << endl;
if(vs[i].lb != vs[i].ub) {
// not implemented
return 1;
}
}
memset(memo, -1, sizeof memo);
ll res = solve(0, nCandy);
printf("%lld\n", res);
return 0;
}
Submission Info
Submission Time |
|
Task |
E - Children and Candies |
User |
ush |
Language |
C++14 (GCC 5.4.1) |
Score |
400 |
Code Size |
1466 Byte |
Status |
RE |
Exec Time |
1384 ms |
Memory |
2176 KB |
Compile Error
./Main.cpp: In function ‘int main()’:
./Main.cpp:58:29: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d%d", &n, &nCandy);
^
./Main.cpp:60:27: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d", &vs[i].lb);
^
./Main.cpp:63:27: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d", &vs[i].ub);
^
Judge Result
Set Name |
Sample |
Subtask |
All |
Score / Max Score |
0 / 0 |
400 / 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 |
RE |
2 ms |
896 KB |
0_001.txt |
AC |
2 ms |
2176 KB |
0_002.txt |
RE |
2 ms |
896 KB |
0_003.txt |
AC |
2 ms |
2176 KB |
0_004.txt |
RE |
2 ms |
896 KB |
1_005.txt |
AC |
2 ms |
2176 KB |
1_006.txt |
AC |
2 ms |
2176 KB |
1_007.txt |
AC |
2 ms |
2176 KB |
1_008.txt |
AC |
2 ms |
2176 KB |
1_009.txt |
AC |
2 ms |
2176 KB |
1_010.txt |
AC |
2 ms |
2176 KB |
1_011.txt |
AC |
2 ms |
2176 KB |
1_012.txt |
AC |
2 ms |
2176 KB |
1_013.txt |
AC |
2 ms |
2176 KB |
1_014.txt |
AC |
1378 ms |
2176 KB |
1_015.txt |
AC |
1378 ms |
2176 KB |
1_016.txt |
AC |
1384 ms |
2176 KB |
2_017.txt |
RE |
2 ms |
896 KB |
2_018.txt |
RE |
2 ms |
896 KB |
2_019.txt |
RE |
2 ms |
896 KB |
2_020.txt |
RE |
2 ms |
896 KB |
2_021.txt |
RE |
2 ms |
896 KB |
2_022.txt |
RE |
2 ms |
896 KB |
2_023.txt |
RE |
2 ms |
896 KB |
2_024.txt |
RE |
2 ms |
896 KB |
2_025.txt |
RE |
2 ms |
896 KB |
2_026.txt |
RE |
2 ms |
896 KB |
2_027.txt |
RE |
2 ms |
896 KB |
2_028.txt |
RE |
2 ms |
896 KB |
2_029.txt |
RE |
2 ms |
896 KB |