QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#483199 | #6743. water235 | ucup-team052# | WA | 79ms | 81868kb | C++14 | 1.3kb | 2024-07-18 13:21:11 | 2024-07-18 13:21:11 |
Judging History
answer
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);++i)
#define per(i,a,b) for(int i=(a);i>=(b);--i)
using namespace std;
const int P=998244353;
int ad(int k1,int k2){return k1+k2>=P?k1+k2-P:k1+k2;}
int su(int k1,int k2){return k1-k2<0?k1-k2+P:k1-k2;}
int mu(int k1,int k2){return 1ULL*k1*k2%P;}
void uad(int&k1,int k2){(k1+=k2)>=P&&(k1-=P);}
void usu(int&k1,int k2){(k1-=k2)<0&&(k1+=P);}
template<class... T>int ad(int k1,T... k2){return ad(k1,ad(k2...));}
template<class... T>int su(int k1,T... k2){return su(k1,ad(k2...));}
template<class... T>int mu(int k1,T... k2){return mu(k1,mu(k2...));}
template<class... T>void uad(int&k1,T... k2){return uad(k1,ad(k2...));}
template<class... T>void usu(int&k1,T... k2){return usu(k1,ad(k2...));}
int po(int k1,int k2){
int k3=1;
for(;k2;k2>>=1,k1=mu(k1,k1))if(k2&1)k3=mu(k3,k1);
return k3;
}
const int N=10000005;
int n,fac[N],ifac[N];
int calc(int l,int r){
if(l<=r&&l>=1)return mu(fac[r],ifac[l-1]);else return 0;
}
int main() {
#ifdef xay5421
freopen("a.in","r",stdin);
#endif
fac[0]=1;
rep(i,1,N-1)fac[i]=mu(fac[i-1],i);
ifac[N-1]=po(fac[N-1],P-2);
per(i,N-1,1)ifac[i-1]=mu(ifac[i],i);
cin>>n;
int ans=0;
rep(i,1,n){
uad(ans,mu(calc(n-i-(i-1),n-i),fac[n-i]));
}
printf("%d\n",ans);
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 79ms
memory: 81868kb
input:
2 1
output:
1
result:
wrong output format Unexpected end of file - int32 expected