QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#241565 | #5. 在线 O(1) 逆元 | Endline | 0 | 711ms | 394540kb | C++14 | 380b | 2023-11-06 11:47:30 | 2024-11-05 21:55:05 |
Judging History
answer
#include<bits/stdc++.h>
#include"inv.h"
#define MAXN 100000002
using namespace std;
const int mod=998244353;
int now,Inv[MAXN];
int calc(int x,int mod)
{
if(x<=now)return Inv[x];
return (mod-mod/x)*calc(mod%x,mod)%mod;
}
void init(int p)
{
Inv[1]=1,now=1;
for(int i=2;i<=100000000;i++)
Inv[i]=calc(i,mod),now=i;
}
int inv(int x)
{
return calc(x,mod);
}
Details
Pretests
Final Tests
Test #1:
score: 0
Wrong Answer
time: 697ms
memory: 394524kb
Test #2:
score: 0
Wrong Answer
time: 707ms
memory: 394472kb
Test #3:
score: 0
Wrong Answer
time: 711ms
memory: 394540kb
Test #4:
score: 0
Wrong Answer
time: 704ms
memory: 394408kb
Test #5:
score: 0
Wrong Answer
time: 695ms
memory: 394524kb