QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#411432#6736. Alice and BobYmkTL 0ms0kbC++231.4kb2024-05-15 13:41:222024-05-15 13:41:22

Judging History

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

  • [2024-05-15 13:41:22]
  • 评测
  • 测评结果:TL
  • 用时:0ms
  • 内存:0kb
  • [2024-05-15 13:41:22]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pair pair<int,int>
#define endl '\n'
#define N (int)1e7+2
#define INF 0x3f3f3f3f//锟斤拷锟斤拷锟� INT_MAX 锟斤拷锟斤拷小 INT_MIN
const int mod=998244353;
ll fact[N],f[N],infact[N];
int qmi(int a, int k, int p) {
    int res = 1 % p;
    while (k) {
        if (k & 1) res = (ll)res * a % p;
        a = (ll)a * a % p;
        k >>= 1;
    }
    return res;
}
ll A(int n, int m,int p) {
	ll res = 1;
	res=fact[n]*infact[n-m]%p;
    
    return res;
}
void solve()
{
    ll x,sum=0;
    cin>>x;
    sum=(sum+A(x-1,x-1,mod))%mod;
    for(ll i=x-2,j=1;i>j;i--,j++)
    {
        // cout<<i<<" "<<j<<endl;
        sum=(sum+(A(i,j,mod)*A(i,i,mod))%mod)%mod;
    }
    
    cout<<sum%mod<<endl;
}
int main()
{
    std::ios::sync_with_stdio(false);
    cin.tie(0),cout.tie(0);
    int t=1;
    // cin>>t;
    fact[0]=infact[0]=1;
    for (int i = 1; i < N; i ++ )
    {
        fact[i] = (ll)fact[i - 1] * i % mod;
        infact[i] = (ll)infact[i - 1] * qmi(i, mod - 2, mod) % mod;
    }
    // f[0]=1;
    // f[1]=1;
    // for(int i=2;i<N-1;i++)
    // {
    //     f[i]=(long long)(mod-mod/i)*(f[mod%i])%mod;
    // }
    // for(int i=0;i<20;i++)
    //     cout<<f[i]<<" "<<infact[i]<<endl;
    while(t--)
        solve();
    // cout<<A(10,10,mod);
    return 0;
}

詳細信息

Test #1:

score: 0
Time Limit Exceeded

input:

1

output:


result: