QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#367841#6736. Alice and Bob1677118046#WA 1ms5624kbC++17979b2024-03-26 15:18:042024-03-26 15:18:05

Judging History

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

  • [2024-03-26 15:18:05]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:5624kb
  • [2024-03-26 15:18:04]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int nn=1e7+10;
ll dp[nn];
const ll mod=998244353;
ll pow1(ll bas,ll y){
	ll ba=1;
	while(y){
		if(y&1){
			ba*=bas;
			ba%=mod;
		}
		y/=2;
		bas*=bas;
		bas%=mod;
	}
	return ba;
}
ll ji[nn];
ll inv[nn];
ll n;
void init(){
	ji[0]=1;
	for(ll i=1;i<=n;i++){
		ji[i]=ji[i-1]*i;
		ji[i]%=mod;
	}
	inv[n]=pow1(ji[n],mod-2);
	for(ll i=n-1;i>=1;i--){
		inv[i]=inv[i+1]*(i+1);
		inv[i]%=mod;
	}
}
void solve(){
	cin>>n;
	ll ans=0;
	init();
	for(ll i=1;i<=(n+1)/2;i++){
		ll an1=1;
		/*
		for(ll j=1;j<=i-1;j++){
			an1*=(n-i-j+1);
		}
		*/
		/*
		for(int j=1;j<=n-i;j++){
			an1*=j;
		}
		*/
		ll pos1=n-i;
		ll pos2=n-2*i+2;
		an1 *= (ji[pos1] % mod * inv[pos2-1] % mod) % mod;
		an1 %= mod;
		an1*=ji[pos1];
		
		an1%=mod;
		ans+=an1;
		ans%=mod;
	}
	cout<<ans<<"\n";
}
int main(){
	ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	solve();
} 

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 1ms
memory: 5624kb

input:

1

output:

0

result:

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