Submission #2241478
Source Code Expand
#include<bits/stdc++.h>
#define rep(i,x,y) for (int i=(x); i<=(y); i++)
#define ll long long
#define N 405
#define mod 1000000007
using namespace std;
int n,c,a[N],b[N],sum[N][N],f[2][N];
void upd(int &x,int y){ x+=y; if (x>=mod) x-=mod; }
void pre(){
rep (i,1,N-1){//sum[i][j]=1^j+2^j+3^j+...+i^j;
sum[i][0]=1;
rep (j,1,N-1) sum[i][j]=(ll)sum[i][j-1]*i%mod;//i^j
rep (j,0,N-1) upd(sum[i][j],sum[i-1][j]);
}
}
int main(){
scanf("%d%d",&n,&c);
pre();
rep (i,1,n) scanf("%d",&a[i]);
rep (i,1,n) scanf("%d",&b[i]);
int nk=0,k=1;
f[0][0]=1;//f[i][j]表示前i个小朋友分了j颗糖
rep (i,0,n-1){
k^=1; nk^=1; memset(f[nk],0,sizeof(f[nk]));
rep (j,0,c) for (int t=0; t+j<=c; t++)//这一轮分了t颗糖
upd(f[nk][t+j],(ll)f[k][j]*(sum[b[i+1]][t]+mod-sum[a[i+1]-1][t])%mod);
}
printf("%d\n",f[nk][c]);
return 0;
}
Submission Info
Submission Time |
|
Task |
E - Children and Candies |
User |
Meetc |
Language |
C++14 (GCC 5.4.1) |
Score |
800 |
Code Size |
866 Byte |
Status |
AC |
Exec Time |
277 ms |
Memory |
896 KB |
Compile Error
./Main.cpp: In function ‘int main()’:
./Main.cpp:17:21: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d%d",&n,&c);
^
./Main.cpp:19:31: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
rep (i,1,n) scanf("%d",&a[i]);
^
./Main.cpp:20:31: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
rep (i,1,n) scanf("%d",&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 |
3 ms |
896 KB |
0_001.txt |
AC |
3 ms |
896 KB |
0_002.txt |
AC |
3 ms |
896 KB |
0_003.txt |
AC |
3 ms |
896 KB |
0_004.txt |
AC |
3 ms |
896 KB |
1_005.txt |
AC |
3 ms |
896 KB |
1_006.txt |
AC |
3 ms |
896 KB |
1_007.txt |
AC |
3 ms |
896 KB |
1_008.txt |
AC |
3 ms |
896 KB |
1_009.txt |
AC |
3 ms |
896 KB |
1_010.txt |
AC |
3 ms |
896 KB |
1_011.txt |
AC |
3 ms |
896 KB |
1_012.txt |
AC |
3 ms |
896 KB |
1_013.txt |
AC |
3 ms |
896 KB |
1_014.txt |
AC |
107 ms |
896 KB |
1_015.txt |
AC |
277 ms |
896 KB |
1_016.txt |
AC |
276 ms |
896 KB |
2_017.txt |
AC |
3 ms |
896 KB |
2_018.txt |
AC |
3 ms |
896 KB |
2_019.txt |
AC |
3 ms |
896 KB |
2_020.txt |
AC |
3 ms |
896 KB |
2_021.txt |
AC |
3 ms |
896 KB |
2_022.txt |
AC |
3 ms |
896 KB |
2_023.txt |
AC |
277 ms |
896 KB |
2_024.txt |
AC |
277 ms |
896 KB |
2_025.txt |
AC |
46 ms |
896 KB |
2_026.txt |
AC |
4 ms |
896 KB |
2_027.txt |
AC |
219 ms |
896 KB |
2_028.txt |
AC |
6 ms |
896 KB |
2_029.txt |
AC |
4 ms |
896 KB |