QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#760402#8023. The Journey of Geor AutumnWithersWA 21ms52108kbC++14921b2024-11-18 16:48:402024-11-18 16:49:07

Judging History

This is the latest submission verdict.

  • [2024-11-18 16:49:07]
  • Judged
  • Verdict: WA
  • Time: 21ms
  • Memory: 52108kb
  • [2024-11-18 16:48:40]
  • Submitted

answer

#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define int long long
#define endl '\n'
int n,m,k;
const int mod=998244353;
int fac[10000010],inv[10000010],ifac[1000010];
int ksm(int x,int y,int mod)
{
	int ans=1,res=x;
	while(y)
	{
		if(y&1) ans=ans*res%mod;
		res=res*res%mod;
		y>>=1;
	}
	return ans;
}
int dp[10000010],pre[10000010];
signed main()
{
	ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	cin>>n>>k;
	fac[0]=1;
	rep(i,1,n) fac[i]=fac[i-1]*i%mod;
	ifac[n]=ksm(fac[n],mod-2,mod);
	for(int i=n-1;i>=0;i--) ifac[i]=ifac[i+1]*(i+1)%mod;
	inv[0]=1;
	rep(i,1,n) inv[i]=fac[i-1]*ifac[i]%mod;
	rep(i,1,k) dp[i]=1,pre[i]=pre[i-1]+dp[i];
	rep(i,k+1,n)
	{
		//cout<<inv[i]<<endl;
		dp[i]=(pre[i-1]-pre[i-k-1]+mod)*inv[i]%mod;
        pre[i]=(pre[i-1]+dp[i])%mod;
	}
//	cout<<dp[n]<<endl;
	rep(i,1,n) dp[n]*=i,dp[n]%=mod;
	cout<<dp[n];
}

详细

Test #1:

score: 100
Accepted
time: 2ms
memory: 11728kb

input:

1 1

output:

1

result:

ok "1"

Test #2:

score: 0
Accepted
time: 2ms
memory: 11776kb

input:

1 2

output:

1

result:

ok "1"

Test #3:

score: 0
Accepted
time: 2ms
memory: 11724kb

input:

1 3

output:

1

result:

ok "1"

Test #4:

score: 0
Accepted
time: 2ms
memory: 11712kb

input:

1 4

output:

1

result:

ok "1"

Test #5:

score: 0
Accepted
time: 2ms
memory: 11708kb

input:

2 1

output:

1

result:

ok "1"

Test #6:

score: 0
Accepted
time: 2ms
memory: 11796kb

input:

2 2

output:

2

result:

ok "2"

Test #7:

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

input:

2 3

output:

2

result:

ok "2"

Test #8:

score: 0
Accepted
time: 2ms
memory: 11852kb

input:

2 4

output:

2

result:

ok "2"

Test #9:

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

input:

3 1

output:

1

result:

ok "1"

Test #10:

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

input:

3 2

output:

4

result:

ok "4"

Test #11:

score: 0
Accepted
time: 2ms
memory: 11724kb

input:

3 3

output:

6

result:

ok "6"

Test #12:

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

input:

3 4

output:

6

result:

ok "6"

Test #13:

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

input:

4 1

output:

1

result:

ok "1"

Test #14:

score: 0
Accepted
time: 2ms
memory: 11724kb

input:

4 2

output:

10

result:

ok "10"

Test #15:

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

input:

4 3

output:

18

result:

ok "18"

Test #16:

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

input:

4 4

output:

24

result:

ok "24"

Test #17:

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

input:

99 50

output:

955866606

result:

ok "955866606"

Test #18:

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

input:

99 70

output:

296999003

result:

ok "296999003"

Test #19:

score: 0
Accepted
time: 2ms
memory: 11748kb

input:

1034 998

output:

637688669

result:

ok "637688669"

Test #20:

score: 0
Accepted
time: 2ms
memory: 11792kb

input:

1099 997

output:

712935289

result:

ok "712935289"

Test #21:

score: 0
Accepted
time: 2ms
memory: 11936kb

input:

10314 998

output:

224695890

result:

ok "224695890"

Test #22:

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

input:

10929 9974

output:

160291286

result:

ok "160291286"

Test #23:

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

input:

103124 99448

output:

695932649

result:

ok "695932649"

Test #24:

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

input:

109139 9937

output:

268916696

result:

ok "268916696"

Test #25:

score: -100
Wrong Answer
time: 21ms
memory: 52108kb

input:

1031234 99238

output:

362860891

result:

wrong answer 1st words differ - expected: '441457721', found: '362860891'