QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#241569 | #5. 在线 O(1) 逆元 | Endline | 80 | 5142ms | 394500kb | C++14 | 364b | 2023-11-06 11:50:48 | 2024-11-05 21:55:06 |
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)
{
if(x<=now)return Inv[x];
return 1ll*(mod-mod/x)*calc(mod%x)%mod;
}
void init(int p)
{
Inv[1]=1,now=1;
for(int i=2;i<=100000000;i++)
Inv[i]=calc(i),now=i;
}
int inv(int x)
{
return calc(x);
}
Details
Pretests
Final Tests
Test #1:
score: 10
Accepted
time: 914ms
memory: 394384kb
Test #2:
score: 20
Accepted
time: 1212ms
memory: 394368kb
Test #3:
score: 30
Accepted
time: 4000ms
memory: 394496kb
Test #4:
score: 20
Accepted
time: 5142ms
memory: 394500kb
Test #5:
score: 0
Time Limit Exceeded