QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#762443#8023. The Journey of Geor AutumnrainygameWA 1ms9892kbC++14719b2024-11-19 15:00:272024-11-19 15:00:37

Judging History

This is the latest submission verdict.

  • [2024-11-19 15:00:37]
  • Judged
  • Verdict: WA
  • Time: 1ms
  • Memory: 9892kb
  • [2024-11-19 15:00:27]
  • Submitted

answer

#include <bits/stdc++.h>
using namespace std;
#define int long long
#define MAXN 10000005
const int MOD(998244353);

int n, k;
int f[MAXN], s[MAXN], fac[MAXN], ifac[MAXN];

int qpow(int x, int k=MOD-2){int res(1); for (; k; k>>=1, (x*=x)%=MOD) if (k&1) (res*=x)%=MOD; return res;}

signed main(){
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	
	cin >> n >> k; f[0] = s[0] = 1;
	fac[0] = 1; for (int i(1); i<=n; ++i) fac[i] = (fac[i-1]*i) % MOD;
	ifac[n] = qpow(fac[n]); for (int i(n-1); i; --i) ifac[i] = (ifac[i+1]*(i+1)) % MOD;
	for (int i(1); i<=n; ++i) f[i] = fac[i-1]*(s[i-1]-(i <= k ? 0 : s[i-min(i, k)-1]))%MOD, s[i] = (s[i-1]+f[i]*ifac[i]) % MOD;
	cout << f[n];
	
	return 0;
}

详细

Test #1:

score: 100
Accepted
time: 1ms
memory: 9740kb

input:

1 1

output:

1

result:

ok "1"

Test #2:

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

input:

1 2

output:

1

result:

ok "1"

Test #3:

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

input:

1 3

output:

1

result:

ok "1"

Test #4:

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

input:

1 4

output:

1

result:

ok "1"

Test #5:

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

input:

2 1

output:

1

result:

ok "1"

Test #6:

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

input:

2 2

output:

2

result:

ok "2"

Test #7:

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

input:

2 3

output:

2

result:

ok "2"

Test #8:

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

input:

2 4

output:

2

result:

ok "2"

Test #9:

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

input:

3 1

output:

1

result:

ok "1"

Test #10:

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

input:

3 2

output:

4

result:

ok "4"

Test #11:

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

input:

3 3

output:

6

result:

ok "6"

Test #12:

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

input:

3 4

output:

6

result:

ok "6"

Test #13:

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

input:

4 1

output:

1

result:

ok "1"

Test #14:

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

input:

4 2

output:

10

result:

ok "10"

Test #15:

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

input:

4 3

output:

18

result:

ok "18"

Test #16:

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

input:

4 4

output:

24

result:

ok "24"

Test #17:

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

input:

99 50

output:

955866606

result:

ok "955866606"

Test #18:

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

input:

99 70

output:

296999003

result:

ok "296999003"

Test #19:

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

input:

1034 998

output:

637688669

result:

ok "637688669"

Test #20:

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

input:

1099 997

output:

712935289

result:

ok "712935289"

Test #21:

score: -100
Wrong Answer
time: 0ms
memory: 9892kb

input:

10314 998

output:

-773548463

result:

wrong answer 1st words differ - expected: '224695890', found: '-773548463'