QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#464892#5. 在线 O(1) 逆元ETO_leader100 ✓5388ms394020kbC++23671b2024-07-06 15:43:142024-07-06 15:43:16

Judging History

你现在查看的是测评时间为 2024-07-06 15:43:16 的历史记录

  • [2024-11-05 21:59:50]
  • 管理员手动重测本题所有提交记录
  • 测评结果:100
  • 用时:5746ms
  • 内存:393832kb
  • [2024-07-06 15:43:16]
  • 评测
  • 测评结果:100
  • 用时:5388ms
  • 内存:394020kb
  • [2024-07-06 15:43:14]
  • 提交

answer

#include<vector>
#define cir(i,a,b) for(int i=a;i<b;++i)
using std::vector;
using ulint=unsigned long long;
static constexpr auto MOD=998244353;
static constexpr auto mx=100000007;
vector<unsigned> q(mx);
constexpr auto Inv(ulint x){
    auto res=1ull;auto b=MOD-2;
    while(b){
        if(b&1) (res*=x)%=MOD;
        (x*=x)%=MOD;b>>=1;
    }
    return res;
}
void init(int p){
    q[0]=1;
    cir(i,1,mx){
        q[i]=(1ull*q[i-1]*i)%MOD;
    }
    auto iv=Inv(q[mx-1]);
    for(auto i=mx-1;i;--i){
        q[i]=(iv*q[i-1])%MOD;
        iv=(1ull*iv*i)%MOD;
    }
}
int inv(int x){
    return x<mx?q[x]:MOD-(1ll)*(MOD/x)*inv(MOD%x)%MOD;
}

Details

Test #1:

score: 30
Accepted
time: 770ms
memory: 394020kb

Test #2:

score: 40
Accepted
time: 1227ms
memory: 393800kb

Test #3:

score: 30
Accepted
time: 5388ms
memory: 393844kb