QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#850057#5. 在线 O(1) 逆元mnbvcxz12310 43ms8436kbC++23404b2025-01-09 20:02:292025-01-09 20:02:30

Judging History

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

  • [2025-01-09 20:02:30]
  • 评测
  • 测评结果:10
  • 用时:43ms
  • 内存:8436kb
  • [2025-01-09 20:02:29]
  • 提交

answer

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

constexpr int mod=998244353;

map<int,int>mp;

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

void init(int p){}

int inv(int x){
    if(mp.count(x))return mp[x];
    return mp[x]=exp(x,mod-2);
}

Details


Pretests


Final Tests

Test #1:

score: 10
Accepted
time: 43ms
memory: 8436kb

Test #2:

score: 0
Time Limit Exceeded

Test #3:

score: 0
Time Limit Exceeded

Test #4:

score: 0
Time Limit Exceeded

Test #5:

score: 0
Time Limit Exceeded