QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#762666#8023. The Journey of Geor AutumnzhichengWA 1ms6012kbC++14770b2024-11-19 16:04:382024-11-19 16:04:47

Judging History

This is the latest submission verdict.

  • [2024-11-19 16:04:47]
  • Judged
  • Verdict: WA
  • Time: 1ms
  • Memory: 6012kb
  • [2024-11-19 16:04:38]
  • Submitted

answer

#include<bits/stdc++.h>
using namespace std;
const int N=10000010,mod=998244353;
int dp[N],inv[N];
void adc(int &x,int y){
	x+=y;
	if(x>=mod){
		x-=mod;
	}
}
int qpow(int a,int b){
	int ans=1;
	while(b){
		if(b&1){
			ans=1ll*ans*a%mod;
		}
		a=1ll*a*a%mod;
		b>>=1;
	}
	return ans;
}
int main(){
	int n,k,ans=0;
	scanf("%d%d",&n,&k);
	inv[1]=dp[0]=1;
	for(int i=1;i<=n-1;i++){
		dp[0]=1ll*dp[0]*i%mod;
	}
	for(int i=2;i<=n;i++){
		inv[i]=1ll*(mod-mod/i)*inv[mod%i]%mod;
	}
	if(k==n){
		ans=dp[0];
	}
	for(int i=1;i<=n-1;i++){
		dp[i]=dp[i-1];
		if(i>=k+1){
			dp[i]=(dp[i]-dp[i-k-1]+mod)%mod;
		}
		dp[i]=1ll*dp[i]*inv[n-i]%mod;
		if(i>=n-k){
			ans=(ans+dp[i])%mod;
		}
		dp[i]=(dp[i]+dp[i-1])%mod;
	}
	printf("%d",ans);
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

1 1

output:

1

result:

ok "1"

Test #2:

score: -100
Wrong Answer
time: 1ms
memory: 6012kb

input:

1 2

output:

0

result:

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