Submission #1290282
Source Code Expand
#include <cstdio>
#include <algorithm>
#define N 4006
#define mo 924844033
using namespace std;
int n,k,t,ans,v[N][2],a[N],g[N],fac[N],f[N][N][2];
int main()
{
scanf("%d%d",&n,&k);
for(int i=1;i<=n;i++)
for(int j=0;j<=1;j++)if(!v[i][j]){
int len=0;
for(int x=i,y=j;x<=n;x+=k,y^=1)++len,v[x][y]=1;
a[t+=len]=1;
}
f[0][0][1]=1;
for(int i=0;i<=t;i++)
for(int j=0;j<=n;j++){
f[i+1][j][0]=(f[i][j][0]+f[i][j][1])%mo;
if(!a[i])f[i+1][j+1][1]=f[i][j][0];
}
for(int i=1;i<=n;i++)g[i]=(f[t][i][0]+f[t][i][1])%mo;
fac[0]=1;for(int i=1;i<=n;i++)fac[i]=1LL*fac[i-1]*i%mo;ans=fac[n];
for(int i=1,j=-1;i<=n;i++,j=-j)ans=(ans+1LL*j*g[i]%mo*fac[n-i]%mo+mo)%mo;
printf("%d\n",ans);
}
Submission Info
Submission Time
2017-05-16 12:38:55+0900
Task
D - ~K Perm Counting
User
wtl666wtl
Language
C++14 (GCC 5.4.1)
Score
900
Code Size
722 Byte
Status
AC
Exec Time
43 ms
Memory
124544 KB
Compile Error
./Main.cpp: In function ‘int main()’:
./Main.cpp:9: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
900 / 900
Status
Set Name
Test Cases
Sample
example0, example1, example2, example3, example4
All
example0, example1, example2, example3, example4, handmade0, handmade1, handmade2, handmade3, handmade4, handmade5, handmade6, maxrand0, maxrand1, maxrand2, maxrand3, maxrand4, rand0, rand1, rand2, rand3, rand4, small0, small1, small2, supersmall0, supersmall1, supersmall2
Case Name
Status
Exec Time
Memory
example0
AC
1 ms
256 KB
example1
AC
1 ms
256 KB
example2
AC
1 ms
256 KB
example3
AC
1 ms
256 KB
example4
AC
7 ms
27264 KB
handmade0
AC
1 ms
256 KB
handmade1
AC
43 ms
124544 KB
handmade2
AC
41 ms
124544 KB
handmade3
AC
39 ms
118144 KB
handmade4
AC
37 ms
116096 KB
handmade5
AC
43 ms
124544 KB
handmade6
AC
43 ms
124544 KB
maxrand0
AC
39 ms
120192 KB
maxrand1
AC
40 ms
120192 KB
maxrand2
AC
42 ms
124416 KB
maxrand3
AC
40 ms
120192 KB
maxrand4
AC
39 ms
120192 KB
rand0
AC
42 ms
124416 KB
rand1
AC
9 ms
37632 KB
rand2
AC
11 ms
43776 KB
rand3
AC
1 ms
4608 KB
rand4
AC
36 ms
112000 KB
small0
AC
5 ms
19072 KB
small1
AC
3 ms
10752 KB
small2
AC
4 ms
14976 KB
supersmall0
AC
1 ms
256 KB
supersmall1
AC
1 ms
256 KB
supersmall2
AC
1 ms
256 KB