Submission #836804
Source Code Expand
Copy
#include <bits/stdc++.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define RI(X) scanf("%d", &(X))
#define RII(X, Y) scanf("%d%d", &(X), &(Y))
#define RIII(X, Y, Z) scanf("%d%d%d", &(X), &(Y), &(Z))
#define DRI(X) int (X); scanf("%d", &X)
#define DRII(X, Y) int X, Y; scanf("%d%d", &X, &Y)
#define DRIII(X, Y, Z) int X, Y, Z; scanf("%d%d%d", &X, &Y, &Z)
#define RS(X) scanf("%s", (X))
#define CASET int ___T, case_n = 1; scanf("%d ", &___T); while (___T-- > 0)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define PII pair<int,int>
#define VI vector<int>
#define VPII vector<pair<int,int> >
#define PLL pair<long long,long long>
#define VPLL vector<pair<long long,long long> >
#define F first
#define S second
typedef long long LL;
using namespace std;
const int MOD = 1e9+7;
const int SIZE = 401;
LL p[SIZE][SIZE],sum_p[SIZE][SIZE];
LL dp[SIZE][SIZE];
int A[SIZE],B[SIZE];
void ADD(LL& x,LL v){
x=(x+v)%MOD;
if(x<0)x+=MOD;
}
int main(){
REPP(i,1,SIZE){
p[i][0]=1;
sum_p[i][0]=sum_p[i-1][0]+1;
REPP(j,1,SIZE){
p[i][j]=p[i][j-1]*i%MOD;
sum_p[i][j]=(sum_p[i-1][j]+p[i][j])%MOD;
}
}
DRII(N,C);
REP(i,N)RI(A[i]);
REP(i,N)RI(B[i]);
dp[0][0]=1;
REP(i,N){
REP(j,C+1){
if(!dp[i][j])continue;
for(int k=0;j+k<=C;k++){
ADD(dp[i+1][j+k],dp[i][j]*(sum_p[B[i]][k]-sum_p[A[i]-1][k]));
}
}
}
cout<<dp[N][C]<<endl;
return 0;
}
Submission Info
Submission Time |
|
Task |
E - Children and Candies |
User |
dreamoon |
Language |
C++14 (GCC 5.4.1) |
Score |
800 |
Code Size |
1782 Byte |
Status |
AC |
Exec Time |
292 ms |
Memory |
3968 KB |
Compile Error
./Main.cpp: In function ‘int main()’:
./Main.cpp:46:14: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
DRII(N,C);
^
./Main.cpp:47:21: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
REP(i,N)RI(A[i]);
^
./Main.cpp:48:21: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
REP(i,N)RI(B[i]);
^
Judge Result
Set Name |
Sample |
Subtask |
All |
Score / Max Score |
0 / 0 |
400 / 400 |
400 / 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 |
AC |
10 ms |
2816 KB |
0_001.txt |
AC |
10 ms |
2816 KB |
0_002.txt |
AC |
10 ms |
2816 KB |
0_003.txt |
AC |
10 ms |
2816 KB |
0_004.txt |
AC |
9 ms |
2816 KB |
1_005.txt |
AC |
10 ms |
2816 KB |
1_006.txt |
AC |
10 ms |
2816 KB |
1_007.txt |
AC |
10 ms |
2816 KB |
1_008.txt |
AC |
10 ms |
2816 KB |
1_009.txt |
AC |
10 ms |
2816 KB |
1_010.txt |
AC |
10 ms |
2816 KB |
1_011.txt |
AC |
12 ms |
3968 KB |
1_012.txt |
AC |
12 ms |
3968 KB |
1_013.txt |
AC |
14 ms |
3968 KB |
1_014.txt |
AC |
193 ms |
3968 KB |
1_015.txt |
AC |
240 ms |
3968 KB |
1_016.txt |
AC |
283 ms |
3968 KB |
2_017.txt |
AC |
9 ms |
2816 KB |
2_018.txt |
AC |
10 ms |
2816 KB |
2_019.txt |
AC |
9 ms |
2816 KB |
2_020.txt |
AC |
9 ms |
2816 KB |
2_021.txt |
AC |
13 ms |
3968 KB |
2_022.txt |
AC |
13 ms |
3968 KB |
2_023.txt |
AC |
194 ms |
3968 KB |
2_024.txt |
AC |
292 ms |
3968 KB |
2_025.txt |
AC |
50 ms |
3968 KB |
2_026.txt |
AC |
13 ms |
3712 KB |
2_027.txt |
AC |
220 ms |
3968 KB |
2_028.txt |
AC |
15 ms |
3072 KB |
2_029.txt |
AC |
11 ms |
2816 KB |