QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#450322#5099. 朝圣道marherCompile Error//C++141.6kb2024-06-22 09:32:572024-06-22 09:32:57

Judging History

This is the latest submission verdict.

  • [2024-06-22 09:32:57]
  • Judged
  • [2024-06-22 09:32:57]
  • Submitted

answer

#include "pilgrimage.h"
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const ll N=2e6;

void exgcd(ll a,ll b,ll&x,ll&y)
{
    if(b==0)
    {
        x=1;y=0;
        return;
    }
    exgcd(b,a%b,y,x);y-=a/b*x;
}

ll inv(ll a,ll P)
{
    ll x,y;exgcd(a,P,x,y);
    return (x%P+P)%P;
}

ll ksm(ll a,ll b,ll mod)
{
    ll ans=1;
    while(b)
    {
        if(b&1)ans=ans*a%mod;
        b>>=1;a=a*a%mod;
    }
    return ans;
}

struct node
{
    ll p,a,q,cm[N];
    
    void init(ll pp,ll aa,ll qq)
    {
        p=pp;a=aa;q=qq;
        cm[0]=1;
        for(ll i=1;i<=q;i++)
        {
            if(i%p)cm[i]=cm[i-1]*i%q;
            else cm[i]=cm[i-1];
        }
    }

    ll sol(ll n)
    {
        if(n==0)return 1;
        return sol(n/p)*ksm(cm[q],n/q,q)%q*cm[n%q]%q;
    }

    ll binom(ll n,ll m)
    {
        ll cnt=0;
        for(ll i=n;i;i/=p)cnt+=i/p;
        for(ll i=m;i;i/=p)cnt-=i/p;
        for(ll i=n-m;i;i/=p)cnt-=i/p;
        return ksm(p,cnt,q)*sol(n)%q*inv(sol(m)*sol(n-m)%q,q)%q;
    }
}tmp;vector<node>P;

ll mod;

void init(int o,int p)
{
    mod=p;
    for(ll i=2;i<=p;i++)if(p%i==0)
    {
        ll cc=0,t=1;
        while(p%i==0)p/=i,t*=i,cc++;
        tmp.init(i,cc,t);P.push_back(tmp);
    }
}

ll ask(ll n)
{
    ll ans=0;
    for(auto&x:P)ans+=x.binom(2*n,n)*(mod/x.q)%mod*inv(mod/x.q,x.q)%mod;
    return ksm(inv(4,mod),n,mod)*(n%mod)%mod*ans%mod;
}

// main()
// {
//     freopen("in.txt","r",stdin);
//     init(0,999983);
//     ll T;cin>>T;
//     while(T--)
//     {
//         ll x;cin>>x;
//         cout<<ask(x)<<'\n';
//     }
// }

Details

answer.code:78:4: error: ambiguating new declaration of ‘long long int ask(long long int)’
   78 | ll ask(ll n)
      |    ^~~
In file included from answer.code:1:
pilgrimage.h:3:5: note: old declaration ‘int ask(long long int)’
    3 | int ask (long long n);
      |     ^~~