QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#464892#5. 在线 O(1) 逆元ETO_leader100 ✓5746ms393832kbC++23671b2024-07-06 15:43:142024-11-05 21:59:50

Judging History

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

  • [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


Pretests


Final Tests

Test #1:

score: 10
Accepted
time: 766ms
memory: 393800kb

Test #2:

score: 20
Accepted
time: 1282ms
memory: 393756kb

Test #3:

score: 30
Accepted
time: 3260ms
memory: 393756kb

Test #4:

score: 20
Accepted
time: 4728ms
memory: 393756kb

Test #5:

score: 20
Accepted
time: 5746ms
memory: 393832kb