Submission #3457153
Source Code Expand
#include<bits/stdc++.h>
using namespace std;
#define REP(i,st,ed) for(register int i=st,i##end=ed;i<=i##end;++i)
#define DREP(i,st,ed) for(register int i=st,i##end=ed;i>=i##end;--i)
typedef long long ll;
template<typename T>inline bool chkmin(T &x,T y){return (y<x)?(x=y,1):0;}
template<typename T>inline bool chkmax(T &x,T y){return (y>x)?(x=y,1):0;}
inline int read(){
int x;
char c;
int f=1;
while((c=getchar())!='-' && (c>'9' || c<'0'));
if(c=='-') f=-1,c=getchar();
x=c^'0';
while((c=getchar())>='0' && c<='9') x=(x<<1)+(x<<3)+(c^'0');
return x*f;
}
inline ll readll(){
ll x;
char c;
int f=1;
while((c=getchar())!='-' && (c>'9' || c<'0'));
if(c=='-') f=-1,c=getchar();
x=c^'0';
while((c=getchar())>='0' && c<='9') x=(x<<1ll)+(x<<3ll)+(c^'0');
return x*f;
}
const int maxn=2000+10,mod=924844033;
int dp[maxn<<1][maxn][2],fac[maxn];
bool f[maxn<<1];
int main(){
int n=read(),m=read(),ans=0;
for(int i=1,cur=0;i<=m;++i) REP(l,0,1) for(int j=i;j<=n;j+=m) f[++cur]=(i!=j);
fac[0]=1;
REP(i,1,n) fac[i]=(ll)fac[i-1]*i%mod;
dp[0][0][0]=1;
REP(i,1,2*n) REP(j,0,n){
dp[i][j][0]=(dp[i-1][j][0]+dp[i-1][j][1])%mod;
if(j && f[i]) dp[i][j][1]=dp[i-1][j-1][0];
}
REP(i,0,n) ans=(ans+(ll)((i&1)?(mod-1):1)*(dp[2*n][i][0]+dp[2*n][i][1])%mod*fac[n-i])%mod;
printf("%d\n",ans);
return 0;
}
Submission Info
Submission Time |
|
Task |
D - ~K Perm Counting |
User |
zhou888 |
Language |
C++14 (GCC 5.4.1) |
Score |
900 |
Code Size |
1350 Byte |
Status |
AC |
Exec Time |
33 ms |
Memory |
63104 KB |
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 |
5 ms |
13440 KB |
handmade0 |
AC |
1 ms |
256 KB |
handmade1 |
AC |
33 ms |
63104 KB |
handmade2 |
AC |
32 ms |
63104 KB |
handmade3 |
AC |
29 ms |
59648 KB |
handmade4 |
AC |
28 ms |
59648 KB |
handmade5 |
AC |
33 ms |
63104 KB |
handmade6 |
AC |
33 ms |
63104 KB |
maxrand0 |
AC |
30 ms |
61696 KB |
maxrand1 |
AC |
30 ms |
61696 KB |
maxrand2 |
AC |
31 ms |
61952 KB |
maxrand3 |
AC |
30 ms |
61696 KB |
maxrand4 |
AC |
30 ms |
61696 KB |
rand0 |
AC |
32 ms |
62848 KB |
rand1 |
AC |
7 ms |
19840 KB |
rand2 |
AC |
8 ms |
22016 KB |
rand3 |
AC |
2 ms |
2944 KB |
rand4 |
AC |
27 ms |
57600 KB |
small0 |
AC |
4 ms |
9216 KB |
small1 |
AC |
2 ms |
4992 KB |
small2 |
AC |
3 ms |
7168 KB |
supersmall0 |
AC |
1 ms |
256 KB |
supersmall1 |
AC |
1 ms |
256 KB |
supersmall2 |
AC |
1 ms |
256 KB |