QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#640874 | #5. 在线 O(1) 逆元 | masterhuang | 0 | 85ms | 42944kb | C++20 | 358b | 2024-10-14 16:38:16 | 2024-11-05 22:05:44 |
Judging History
answer
#include "inv.h"
#include<bits/stdc++.h>
using namespace std;
const int N=1e7+5,mod=998244353;
int n=N-5,I[N];
void init(int p)
{
I[1]=1;
for(int i=2;i<=n;i++) I[i]=(mod-1ll*(mod/i)*I[mod%i])%mod;
}
int inv(int x)
{
if(x<=n) return I[x];int q=mod/x,r=mod%x;
// if(r<x/2)
return mod-1ll*q*inv(r)%mod;
// return 1ll*(q+1)*inv(x-r)%mod;
}
Details
Pretests
Final Tests
Test #1:
score: 0
Wrong Answer
time: 77ms
memory: 42808kb
Test #2:
score: 0
Wrong Answer
time: 74ms
memory: 42808kb
Test #3:
score: 0
Wrong Answer
time: 85ms
memory: 42792kb
Test #4:
score: 0
Wrong Answer
time: 78ms
memory: 42944kb
Test #5:
score: 0
Wrong Answer
time: 67ms
memory: 42684kb