QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#246039#6736. Alice and BobColblue#TL 0ms0kbC++141.0kb2023-11-10 15:46:282023-11-10 15:46:29

Judging History

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

  • [2023-11-10 15:46:29]
  • 评测
  • 测评结果:TL
  • 用时:0ms
  • 内存:0kb
  • [2023-11-10 15:46:28]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define endl '\n'
typedef long long ll;
const int N=1e7+10,mod=998244353;

ll qpw(ll a,ll n)
{
    ll res=1;
    a%=mod;
    while(n)
    {
        if(n&1)
            res=(res*a)%mod;
        n>>=1;
        a=(a*a)%mod;
    }
    return res;
}
ll fact[N],infact[N];
void init()
{
    fact[0]=infact[0]=1;
    for(int i=1;i<N;i++)
    {
        fact[i]=(fact[i-1]*i)%mod;
        infact[i] =( infact[i-1]*qpw(i,mod-2))%mod;
    }
}

ll C(int a,int b)
{
    if(b>a)
        return 0;
    ll res=1;
	res=((fact[a]*infact[a-b])%mod*infact[b])%mod;
	return res;
}

int a[N];
void solve()
{
    int n;
    cin>>n;
    ll res=0;
    for(int i=1;i<=n;i++)
    {
        ll tmp= (C(n-i,i-1)* fact[i-1])%mod;
        tmp= (tmp*fact[n-i])%mod;
        res=(res+tmp)%mod;
    }
    cout<<res<<endl;
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    init();
    int T;
    //cin>>T;
    T=1;
    while(T--)
        solve();
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Time Limit Exceeded

input:

1

output:


result: