Submission #25477186
Source Code Expand
Copy
#include<bits/stdc++.h>#define int long longusing namespace std;inline int read() {int s=1,a=0;char c=getchar();while(!isdigit(c)) {if(c=='-') s=-s;c=getchar();}while(isdigit(c)) {a=(a<<3)+(a<<1)+c-'0';c=getchar();}return s*a;}const int N=5e3+8,Mod=924844033;int n,k,jc[N],f[N][N][2],vis[N],tot;void init() {jc[0]=1;for(int i=1; i<=n; i++) {
#include<bits/stdc++.h> #define int long long using namespace std; inline int read() { int s=1,a=0; char c=getchar(); while(!isdigit(c)) { if(c=='-') s=-s; c=getchar(); } while(isdigit(c)) { a=(a<<3)+(a<<1)+c-'0'; c=getchar(); } return s*a; } const int N=5e3+8,Mod=924844033; int n,k,jc[N],f[N][N][2],vis[N],tot; void init() { jc[0]=1; for(int i=1; i<=n; i++) { jc[i]=jc[i-1]*i%Mod; } for(int i=1; i<=k; i++) { for(int t=1; t<=2; t++) { for(int j=i; j<=n; j+=k) { tot++; if(j!=i) vis[tot]=1; } } } } signed main() { n=read(),k=read(); init(); f[0][0][0]=1; for(int i=1; i<=(n<<1); i++) { for(int j=0; j<=n; j++) { f[i][j][0]=(f[i-1][j][0]+f[i-1][j][1])%Mod; if(vis[i]&&j>0) f[i][j][1]=f[i-1][j-1][0]; } } int ans=0; for(int i=0; i<=n; i++) { if(i&1) ans=(ans-(f[n<<1][i][0]+f[n<<1][i][1])*jc[n-i]%Mod+Mod)%Mod; else ans=(ans+(f[n<<1][i][0]+f[n<<1][i][1])*jc[n-i]%Mod)%Mod; } printf("%lld\n",ans); return 0; }
Submission Info
Submission Time | |
---|---|
Task | D - ~K Perm Counting |
User | rpdg |
Language | C++ (GCC 9.2.1) |
Score | 900 |
Code Size | 1021 Byte |
Status | AC |
Exec Time | 100 ms |
Memory | 144720 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 | 8 ms | 3560 KB |
example1 | AC | 4 ms | 3716 KB |
example2 | AC | 3 ms | 3508 KB |
example3 | AC | 2 ms | 3704 KB |
example4 | AC | 15 ms | 12728 KB |
handmade0 | AC | 2 ms | 3736 KB |
handmade1 | AC | 100 ms | 144720 KB |
handmade2 | AC | 94 ms | 144696 KB |
handmade3 | AC | 82 ms | 129752 KB |
handmade4 | AC | 83 ms | 123736 KB |
handmade5 | AC | 94 ms | 144660 KB |
handmade6 | AC | 91 ms | 144680 KB |
maxrand0 | AC | 89 ms | 132208 KB |
maxrand1 | AC | 87 ms | 135408 KB |
maxrand2 | AC | 89 ms | 140288 KB |
maxrand3 | AC | 88 ms | 132280 KB |
maxrand4 | AC | 86 ms | 131916 KB |
rand0 | AC | 91 ms | 144256 KB |
rand1 | AC | 18 ms | 20572 KB |
rand2 | AC | 21 ms | 24572 KB |
rand3 | AC | 3 ms | 4676 KB |
rand4 | AC | 78 ms | 117772 KB |
small0 | AC | 9 ms | 8976 KB |
small1 | AC | 8 ms | 5832 KB |
small2 | AC | 6 ms | 7980 KB |
supersmall0 | AC | 2 ms | 3700 KB |
supersmall1 | AC | 2 ms | 3504 KB |
supersmall2 | AC | 2 ms | 3660 KB |