Submission #1817927
Source Code Expand
#include<cstdio>
const int MOD=924844033;
struct mint{int x;mint(int x=0):x(x){}};
inline mint operator+ (mint a,mint b){return a.x+b.x<MOD?a.x+b.x:a.x+b.x-MOD;}
inline mint operator- (mint a){return MOD-a.x;}
inline mint operator- (mint a,mint b){return a+-b;}
inline mint operator* (mint a,mint b){return 1LL*a.x*b.x%MOD;}
inline mint operator<< (mint x,int y){mint r=1;for(;y;y>>=1,x=x*x)if(y&1)r=r*x;return r;}
inline mint operator~ (mint x){return x<<MOD-2;}
inline mint operator/ (mint a,mint b){return a*~b;}
inline mint&operator+= (mint&a,mint b){return a=a+b;}
inline mint&operator-= (mint&a,mint b){return a=a-b;}
inline mint&operator*= (mint&a,mint b){return a=a*b;}
inline mint&operator<<=(mint&x,int y){return x=x<<y;}
inline mint&operator/= (mint&a,mint b){return a=a/b;}
#define MN 2000
mint f[MN+5][MN+5][2],p[MN+5],ans;
int main()
{
int n,k,i,j,l;
scanf("%d%d",&n,&k);
for(f[0][0][0]=i=1;i<=n&&i<=2*k;++i)
{
for(j=0;j<=n;++j)
{
f[i][j][0]+=f[i-1][j][0];
if(i>k)f[i][j+1][0]+=f[i-1][j][0];
if(i+k<=n)f[i][j+1][1]+=f[i-1][j][0];
}
for(l=i;(l+=2*k)<=n;)for(j=0;j<=n;++j)
{
f[l][j][0]+=f[l-2*k][j][0]+f[l-2*k][j][1];
f[l][j+1][0]+=f[l-2*k][j][0];
if(l+k<=n)f[l][j+1][1]+=f[l-2*k][j][0]+f[l-2*k][j][1];
}
for(j=0;j<=n;++j)f[i][j][0]=f[l-2*k][j][0]+f[l-2*k][j][1];
}
for(l=i-1,p[0]=i=1;i<=n;++i)p[i]=p[i-1]*i;
for(i=0;i<=n;++i)ans+=(mint(MOD-1)<<i)*f[l][i][0]*p[n-i];
printf("%d",ans);
}
Submission Info
Submission Time
2017-11-30 18:01:10+0900
Task
D - ~K Perm Counting
User
ditoly
Language
C++14 (GCC 5.4.1)
Score
900
Code Size
1488 Byte
Status
AC
Exec Time
27 ms
Memory
31616 KB
Compile Error
./Main.cpp: In function ‘int main()’:
./Main.cpp:42:17: warning: format ‘%d’ expects argument of type ‘int’, but argument 2 has type ‘mint’ [-Wformat=]
printf("%d",ans);
^
./Main.cpp:23: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
10 ms
31616 KB
example1
AC
10 ms
31616 KB
example2
AC
10 ms
31616 KB
example3
AC
10 ms
31616 KB
example4
AC
11 ms
31616 KB
handmade0
AC
10 ms
31616 KB
handmade1
AC
27 ms
31616 KB
handmade2
AC
21 ms
31616 KB
handmade3
AC
25 ms
31616 KB
handmade4
AC
20 ms
31616 KB
handmade5
AC
27 ms
31616 KB
handmade6
AC
27 ms
31616 KB
maxrand0
AC
22 ms
31616 KB
maxrand1
AC
25 ms
31616 KB
maxrand2
AC
25 ms
31616 KB
maxrand3
AC
25 ms
31616 KB
maxrand4
AC
20 ms
31616 KB
rand0
AC
26 ms
31616 KB
rand1
AC
12 ms
31616 KB
rand2
AC
12 ms
31616 KB
rand3
AC
10 ms
31616 KB
rand4
AC
21 ms
31616 KB
small0
AC
11 ms
31616 KB
small1
AC
10 ms
31616 KB
small2
AC
10 ms
31616 KB
supersmall0
AC
10 ms
31616 KB
supersmall1
AC
10 ms
31616 KB
supersmall2
AC
10 ms
31616 KB