Submission #1693528
Source Code Expand
#include <cstdio>
#include <cstring>
#define MAXN 4010
#define LL long long
const LL P=1000000007;
int n,k;
LL f[MAXN][MAXN],c[MAXN][MAXN],g[MAXN];
void update(LL &x,LL y){ x=(x+y)%P; }
void pre_gao(){
for(int i=0;i<MAXN;i++){
c[i][0]=1;
for(int j=1;j<=i;j++)
c[i][j]=(c[i-1][j-1]+c[i-1][j])%P;
}
}
LL gay(int x,int y){
return c[x+y-1][y];
}
LL gao(){
f[1][1]=1;
for(int i=2;i<=k;i++){
for(int j=1;j<i;j++)
update(f[i][j+1],f[i-1][j]);
LL temp=0;
for(int j=i-1;j>=1;j--){
update(temp,f[i-1][j]);
update(f[i][j],temp);
}
g[i-1]=temp;
}
g[0]=1;
LL ans=g[k-1];
for(int i=1;i<=k-1;i++){
int j=k-1-i;
if(n-2-j>=i){
LL temp=c[n-2-j][i];
if(!j) update(ans,temp);
else{
for(int l=1;l<=j;l++)
update(ans,temp*f[j][l]%P*gay(l+1,i));
}
}
}
for(int i=1;i<n-k;i++) ans=ans*2%P;
return ans;
}
int main(){
#ifdef DEBUG
freopen("F.in","r",stdin);
#endif
scanf("%d%d",&n,&k);
pre_gao();
printf("%lld\n",gao());
}
Submission Info
Submission Time
2017-10-19 18:17:17+0900
Task
F - Solitaire
User
ez_zjt
Language
C++14 (GCC 5.4.1)
Score
1200
Code Size
1033 Byte
Status
AC
Exec Time
98 ms
Memory
186880 KB
Compile Error
./Main.cpp: In function ‘int main()’:
./Main.cpp:58:21: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d%d",&n,&k);
^
Judge Result
Set Name
Sample
All
Score / Max Score
0 / 0
1200 / 1200
Status
Set Name
Test Cases
Sample
00_example_01.txt, 00_example_02.txt, 00_example_03.txt
All
00_example_01.txt, 00_example_02.txt, 00_example_03.txt, 01.txt, 02.txt, 03.txt, 04.txt, 05.txt, 06.txt, 07.txt, 08.txt, 09.txt, 10.txt, 11.txt, 12.txt, 13.txt, 14.txt, 15.txt, 16.txt, 17.txt, 18.txt, 19.txt, 20.txt, 21.txt, 22.txt, 23.txt
Case Name
Status
Exec Time
Memory
00_example_01.txt
AC
51 ms
125312 KB
00_example_02.txt
AC
51 ms
125312 KB
00_example_03.txt
AC
70 ms
156160 KB
01.txt
AC
51 ms
125312 KB
02.txt
AC
66 ms
152064 KB
03.txt
AC
51 ms
125440 KB
04.txt
AC
53 ms
129536 KB
05.txt
AC
51 ms
125440 KB
06.txt
AC
51 ms
125312 KB
07.txt
AC
51 ms
125440 KB
08.txt
AC
51 ms
125440 KB
09.txt
AC
94 ms
176640 KB
10.txt
AC
51 ms
125312 KB
11.txt
AC
51 ms
125312 KB
12.txt
AC
98 ms
180736 KB
13.txt
AC
52 ms
127360 KB
14.txt
AC
62 ms
145920 KB
15.txt
AC
57 ms
139648 KB
16.txt
AC
61 ms
145920 KB
17.txt
AC
59 ms
141824 KB
18.txt
AC
77 ms
164352 KB
19.txt
AC
72 ms
158208 KB
20.txt
AC
58 ms
139776 KB
21.txt
AC
51 ms
125312 KB
22.txt
AC
82 ms
186880 KB
23.txt
AC
51 ms
125312 KB