QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#850078#5. 在线 O(1) 逆元mnbvcxz1230 742ms376084kbC++23566b2025-01-09 20:11:002025-01-09 20:11:03

Judging History

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

  • [2025-01-09 20:11:03]
  • 评测
  • 测评结果:0
  • 用时:742ms
  • 内存:376084kb
  • [2025-01-09 20:11:00]
  • 提交

answer

#include"inv.h"
#include<bits/stdc++.h>
using namespace std;
using ll=long long;

constexpr int mod=998244353;

map<int,int>mp;

int exp(int a, int w){
    int ret=1;
    a%=mod;
    while(w){
        if(w&1)ret=1ll*ret*a%mod;
        a=1ll*a*a%mod;
        w>>=1;
    }
    return ret;
}

int inver[100000000];

int lst=1;

void init(int p){
    inver[1]=1;
}

int inv(int x){
    if(x>=1e8)return exp(x,mod-2);
    while(lst<x){
        inver[lst]=mod-1ll*(mod/lst)*inver[mod%lst]%mod;
        ++lst;
    }
    return inver[x];
}

Details


Pretests


Final Tests

Test #1:

score: 0
Wrong Answer
time: 724ms
memory: 376084kb

Test #2:

score: 0
Wrong Answer
time: 675ms
memory: 313956kb

Test #3:

score: 0
Wrong Answer
time: 665ms
memory: 351532kb

Test #4:

score: 0
Wrong Answer
time: 621ms
memory: 351900kb

Test #5:

score: 0
Wrong Answer
time: 742ms
memory: 361084kb