QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#241448 | #5. 在线 O(1) 逆元 | mfeitveer | 60 | 3821ms | 81904kb | C++14 | 386b | 2023-11-06 07:46:40 | 2024-11-05 21:54:14 |
Judging History
answer
#include "inv.h"
const int N = 10000010;
const int mod = 998244353;
typedef long long ll;
ll Inv[N];
ll ask(ll x)
{
if(x <= 10000000) return Inv[x];
return (mod - mod / x) * ask(mod % x) % mod;
}
void init(int p)
{
Inv[1] = 1;
for(int i = 2;i <= 10000000;i++)
Inv[i] = (mod - mod / i) * Inv[mod % i] % mod;
}
int inv(int x)
{
return ask(x);
}
Details
Pretests
Final Tests
Test #1:
score: 10
Accepted
time: 92ms
memory: 81904kb
Test #2:
score: 20
Accepted
time: 827ms
memory: 81884kb
Test #3:
score: 30
Accepted
time: 3821ms
memory: 81868kb
Test #4:
score: 0
Time Limit Exceeded
Test #5:
score: 0
Time Limit Exceeded