QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#762177#8023. The Journey of Geor AutumnkintsgiAC ✓203ms316192kbC++141.2kb2024-11-19 14:03:062024-11-19 14:03:08

Judging History

你现在查看的是最新测评结果

  • [2024-11-19 14:03:08]
  • 评测
  • 测评结果:AC
  • 用时:203ms
  • 内存:316192kb
  • [2024-11-19 14:03:06]
  • 提交

answer

#include <bits/stdc++.h>
#define mk make_pair
#define pb emplace_back
#define fi first
#define se second
#define pii pair<int, int>
#define fore(i, u, v) for (int i = h[u], v = e[i].v; i; v = e[i = e[i].nxt].v)
#define all(x) x.begin(), x.end()
#define int long long

using namespace std;
inline int read() {
	int x = 0, f = 1;
	char ch = getchar();
	while (! isdigit(ch)) { if (ch == '-') f = -1; ch = getchar(); }
	while (isdigit(ch)) { x = x * 10 + ch - 48; ch = getchar(); }
	return x * f;
}

const int maxn = 1e7 + 10, P = 998244353;

int n, k, f[maxn], inv[maxn], fin[maxn], fac[maxn];
void init() {
	for (int i : {0, 1}) inv[i] = fac[i] = fin[i] = 1;
	for (int i = 2; i < maxn; i ++)
		inv[i] = inv[P % i] * (P - P / i) % P,
		fin[i] = fin[i - 1] * inv[i] % P, fac[i] = fac[i - 1] * i % P;
}

signed main() {

	n = read(), k = read(), init();
	for (int i = n; i >= n - k; i --) f[i] = fac[n - i];

	int sum = 0;
	for (int i = n - k; i <= n - 1; i ++) (sum += f[i] * fin[n - i] % P) %= P;
	for (int i = n - k - 1; i >= 0; i --) {
		f[i] = sum * fac[n - i - 1] % P;
		(sum += f[i] * fin[n - i] % P - f[i + k] * fin[n - i - k] % P + P) %= P;
	}

	cout << f[0];

	return 0;
}

这程序好像有点Bug,我给组数据试试?

詳細信息

Test #1:

score: 100
Accepted
time: 123ms
memory: 238968kb

input:

1 1

output:

1

result:

ok "1"

Test #2:

score: 0
Accepted
time: 151ms
memory: 238828kb

input:

1 2

output:

1

result:

ok "1"

Test #3:

score: 0
Accepted
time: 151ms
memory: 239288kb

input:

1 3

output:

1

result:

ok "1"

Test #4:

score: 0
Accepted
time: 151ms
memory: 238904kb

input:

1 4

output:

1

result:

ok "1"

Test #5:

score: 0
Accepted
time: 142ms
memory: 238504kb

input:

2 1

output:

1

result:

ok "1"

Test #6:

score: 0
Accepted
time: 149ms
memory: 239204kb

input:

2 2

output:

2

result:

ok "2"

Test #7:

score: 0
Accepted
time: 144ms
memory: 239900kb

input:

2 3

output:

2

result:

ok "2"

Test #8:

score: 0
Accepted
time: 133ms
memory: 238796kb

input:

2 4

output:

2

result:

ok "2"

Test #9:

score: 0
Accepted
time: 148ms
memory: 239856kb

input:

3 1

output:

1

result:

ok "1"

Test #10:

score: 0
Accepted
time: 143ms
memory: 239348kb

input:

3 2

output:

4

result:

ok "4"

Test #11:

score: 0
Accepted
time: 136ms
memory: 239672kb

input:

3 3

output:

6

result:

ok "6"

Test #12:

score: 0
Accepted
time: 132ms
memory: 238220kb

input:

3 4

output:

6

result:

ok "6"

Test #13:

score: 0
Accepted
time: 126ms
memory: 239272kb

input:

4 1

output:

1

result:

ok "1"

Test #14:

score: 0
Accepted
time: 142ms
memory: 239984kb

input:

4 2

output:

10

result:

ok "10"

Test #15:

score: 0
Accepted
time: 168ms
memory: 239544kb

input:

4 3

output:

18

result:

ok "18"

Test #16:

score: 0
Accepted
time: 133ms
memory: 239460kb

input:

4 4

output:

24

result:

ok "24"

Test #17:

score: 0
Accepted
time: 143ms
memory: 238284kb

input:

99 50

output:

955866606

result:

ok "955866606"

Test #18:

score: 0
Accepted
time: 135ms
memory: 239212kb

input:

99 70

output:

296999003

result:

ok "296999003"

Test #19:

score: 0
Accepted
time: 161ms
memory: 238576kb

input:

1034 998

output:

637688669

result:

ok "637688669"

Test #20:

score: 0
Accepted
time: 159ms
memory: 238672kb

input:

1099 997

output:

712935289

result:

ok "712935289"

Test #21:

score: 0
Accepted
time: 127ms
memory: 238764kb

input:

10314 998

output:

224695890

result:

ok "224695890"

Test #22:

score: 0
Accepted
time: 144ms
memory: 239360kb

input:

10929 9974

output:

160291286

result:

ok "160291286"

Test #23:

score: 0
Accepted
time: 141ms
memory: 240732kb

input:

103124 99448

output:

695932649

result:

ok "695932649"

Test #24:

score: 0
Accepted
time: 152ms
memory: 239596kb

input:

109139 9937

output:

268916696

result:

ok "268916696"

Test #25:

score: 0
Accepted
time: 170ms
memory: 247832kb

input:

1031234 99238

output:

441457721

result:

ok "441457721"

Test #26:

score: 0
Accepted
time: 136ms
memory: 247200kb

input:

1091239 991237

output:

61047495

result:

ok "61047495"

Test #27:

score: 0
Accepted
time: 196ms
memory: 316192kb

input:

10000000 9982443

output:

224744113

result:

ok "224744113"

Test #28:

score: 0
Accepted
time: 203ms
memory: 316016kb

input:

9999977 5678901

output:

641748125

result:

ok "641748125"

Extra Test:

score: 0
Extra Test Passed