Submission #1806895
Source Code Expand
#include <cstdio> #include <algorithm> typedef long long ll; const int N = 2e3 + 5; const int Mod = 924844033; int n, K; int g[N][N][4], w[2][N], fac[N], ans; int main() { scanf("%d%d", &n, &K); g[0][0][2] = 1; for (int i = 0; i < n; ++i) for (int j = 0; j <= i; ++j) for (int opt = 0; opt < 4; ++opt) if (g[i][j][opt]) { (g[i + 1][j][(opt & 1) << 1] += g[i][j][opt]) %= Mod; (g[i + 1][j + 1][((opt & 1) << 1) | 1] += g[i][j][opt]) %= Mod; if (!(opt >> 1)) (g[i + 1][j + 1][(opt & 1) << 1] += g[i][j][opt]) %= Mod; } int x = 0, y = 1; w[0][0] = 1; for (int c = 0, pre = 0; c < K; ++c, std :: swap(x, y)) { int m = n / K + (c ? c <= (n % K) : 0); pre += m; for (int i = 0; i <= pre; ++i) w[y][i] = 0; for (int v = 0; v <= m; ++v) { int t = (g[m][v][0] + g[m][v][2]) % Mod; for (int i = v; i <= pre; ++i) (w[y][i] += (ll)w[x][i - v] * t % Mod) %= Mod; } } fac[0] = 1; for (int i = 1; i <= n; ++i) fac[i] = (ll)fac[i - 1] * i % Mod; for (int i = 0; i <= n; ++i) if (i & 1) (ans -= (ll)fac[n - i] * w[x][i] % Mod) %= Mod; else (ans += (ll)fac[n - i] * w[x][i] % Mod) %= Mod; if (ans < 0) ans += Mod; printf("%d\n", ans); return 0; }
Submission Info
Submission Time | |
---|---|
Task | D - ~K Perm Counting |
User | wy1627 |
Language | C++14 (GCC 5.4.1) |
Score | 900 |
Code Size | 1246 Byte |
Status | AC |
Exec Time | 75 ms |
Memory | 61184 KB |
Compile Error
./Main.cpp: In function ‘int main()’: ./Main.cpp:9:23: 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 | 128 KB |
example1 | AC | 1 ms | 128 KB |
example2 | AC | 1 ms | 128 KB |
example3 | AC | 1 ms | 128 KB |
example4 | AC | 6 ms | 12800 KB |
handmade0 | AC | 1 ms | 128 KB |
handmade1 | AC | 67 ms | 61184 KB |
handmade2 | AC | 75 ms | 61184 KB |
handmade3 | AC | 60 ms | 57856 KB |
handmade4 | AC | 64 ms | 57856 KB |
handmade5 | AC | 67 ms | 61184 KB |
handmade6 | AC | 67 ms | 61184 KB |
maxrand0 | AC | 68 ms | 59904 KB |
maxrand1 | AC | 66 ms | 59904 KB |
maxrand2 | AC | 68 ms | 60032 KB |
maxrand3 | AC | 61 ms | 59904 KB |
maxrand4 | AC | 68 ms | 59904 KB |
rand0 | AC | 69 ms | 60928 KB |
rand1 | AC | 10 ms | 18944 KB |
rand2 | AC | 12 ms | 20992 KB |
rand3 | AC | 1 ms | 2560 KB |
rand4 | AC | 60 ms | 55808 KB |
small0 | AC | 4 ms | 8704 KB |
small1 | AC | 2 ms | 4608 KB |
small2 | AC | 3 ms | 6656 KB |
supersmall0 | AC | 1 ms | 128 KB |
supersmall1 | AC | 1 ms | 128 KB |
supersmall2 | AC | 1 ms | 128 KB |