QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#762404#8023. The Journey of Geor AutumnliangbowenAC ✓172ms159952kbC++141.2kb2024-11-19 14:54:012024-11-19 14:54:01

Judging History

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

  • [2024-11-19 14:54:01]
  • 评测
  • 测评结果:AC
  • 用时:172ms
  • 内存:159952kb
  • [2024-11-19 14:54:01]
  • 提交

answer

#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#define mems(x, v) memset(x, v, sizeof x)
#define mcpy(x, y) memcpy(x, y, sizeof x)
using namespace std;
typedef pair <int, int> pii;
typedef long long ll;
typedef unsigned long long ull;
typedef long double wisdom;

const int N = 1e7 + 5, mod = 998244353;
int qpow(int x, int y) {int ans = 1; while (y) {if (y & 1) ans = 1ll * ans * x % mod; x = 1ll * x * x % mod; y >>= 1;} return ans;}
int dp[N], qwq[N], fac[N], invf[N];
int main() {
	//freopen("b.in", "r", stdin); freopen("b.out", "w", stdout);
	int n, k; cin >> n >> k, dp[0] = fac[0] = invf[0] = 1;
	for (int i = 1; i <= n; i++) fac[i] = 1ll * fac[i - 1] * i % mod;
	invf[n] = qpow(fac[n], mod - 2); for (int i = n - 1; i; i--) invf[i] = 1ll * invf[i + 1] * (i + 1) % mod;

	// for (int i = 1; i <= n; i++) for (int j = max(0, i - k); j < i; j++)
	// 	dp[i] = (dp[i] + 1ll * fac[n - j - 1] * invf[n - i] % mod * dp[j]) % mod;

	qwq[0] = fac[n - 1];
	for (int i = 1; i <= n; i++)
		dp[i] = 1ll * (qwq[i - 1] - (i <= k ? 0 : qwq[i - k - 1]) + mod) * invf[n - i] % mod, qwq[i] = (qwq[i - 1] + 1ll * dp[i] * fac[n - i - 1]) % mod;
	cout << dp[n];
	return 0;
}

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

詳細信息

Test #1:

score: 100
Accepted
time: 0ms
memory: 9720kb

input:

1 1

output:

1

result:

ok "1"

Test #2:

score: 0
Accepted
time: 1ms
memory: 9660kb

input:

1 2

output:

1

result:

ok "1"

Test #3:

score: 0
Accepted
time: 1ms
memory: 9844kb

input:

1 3

output:

1

result:

ok "1"

Test #4:

score: 0
Accepted
time: 1ms
memory: 9656kb

input:

1 4

output:

1

result:

ok "1"

Test #5:

score: 0
Accepted
time: 0ms
memory: 9780kb

input:

2 1

output:

1

result:

ok "1"

Test #6:

score: 0
Accepted
time: 0ms
memory: 9840kb

input:

2 2

output:

2

result:

ok "2"

Test #7:

score: 0
Accepted
time: 1ms
memory: 9784kb

input:

2 3

output:

2

result:

ok "2"

Test #8:

score: 0
Accepted
time: 1ms
memory: 9800kb

input:

2 4

output:

2

result:

ok "2"

Test #9:

score: 0
Accepted
time: 1ms
memory: 9664kb

input:

3 1

output:

1

result:

ok "1"

Test #10:

score: 0
Accepted
time: 1ms
memory: 9796kb

input:

3 2

output:

4

result:

ok "4"

Test #11:

score: 0
Accepted
time: 0ms
memory: 9800kb

input:

3 3

output:

6

result:

ok "6"

Test #12:

score: 0
Accepted
time: 0ms
memory: 9712kb

input:

3 4

output:

6

result:

ok "6"

Test #13:

score: 0
Accepted
time: 0ms
memory: 9720kb

input:

4 1

output:

1

result:

ok "1"

Test #14:

score: 0
Accepted
time: 1ms
memory: 9836kb

input:

4 2

output:

10

result:

ok "10"

Test #15:

score: 0
Accepted
time: 1ms
memory: 9844kb

input:

4 3

output:

18

result:

ok "18"

Test #16:

score: 0
Accepted
time: 1ms
memory: 9788kb

input:

4 4

output:

24

result:

ok "24"

Test #17:

score: 0
Accepted
time: 0ms
memory: 9840kb

input:

99 50

output:

955866606

result:

ok "955866606"

Test #18:

score: 0
Accepted
time: 0ms
memory: 9660kb

input:

99 70

output:

296999003

result:

ok "296999003"

Test #19:

score: 0
Accepted
time: 0ms
memory: 9728kb

input:

1034 998

output:

637688669

result:

ok "637688669"

Test #20:

score: 0
Accepted
time: 1ms
memory: 9840kb

input:

1099 997

output:

712935289

result:

ok "712935289"

Test #21:

score: 0
Accepted
time: 0ms
memory: 9796kb

input:

10314 998

output:

224695890

result:

ok "224695890"

Test #22:

score: 0
Accepted
time: 1ms
memory: 9820kb

input:

10929 9974

output:

160291286

result:

ok "160291286"

Test #23:

score: 0
Accepted
time: 3ms
memory: 10112kb

input:

103124 99448

output:

695932649

result:

ok "695932649"

Test #24:

score: 0
Accepted
time: 3ms
memory: 10204kb

input:

109139 9937

output:

268916696

result:

ok "268916696"

Test #25:

score: 0
Accepted
time: 22ms
memory: 27680kb

input:

1031234 99238

output:

441457721

result:

ok "441457721"

Test #26:

score: 0
Accepted
time: 18ms
memory: 26732kb

input:

1091239 991237

output:

61047495

result:

ok "61047495"

Test #27:

score: 0
Accepted
time: 172ms
memory: 159940kb

input:

10000000 9982443

output:

224744113

result:

ok "224744113"

Test #28:

score: 0
Accepted
time: 164ms
memory: 159952kb

input:

9999977 5678901

output:

641748125

result:

ok "641748125"

Extra Test:

score: 0
Extra Test Passed