QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#268028 | #5. 在线 O(1) 逆元 | David713 | 0 | 831ms | 394528kb | C++14 | 403b | 2023-11-27 22:58:01 | 2024-11-05 21:55:44 |
Judging History
answer
#include "inv.h"
#include <bits/stdc++.h>
using namespace std;
const int mod = 998244353, N = 1e8 + 10;
typedef long long ll;
int invv[N];
void init(int p)
{
invv[0] = invv[1] = 1;
for (int i = 2; i <= 1e8; i++) invv[i] = ll((mod - mod / i) * invv[mod % i]) % mod;
}
int inv(int x)
{
if (x <= 1e8) return invv[x];
return ((ll)(mod - mod / x) * (ll)(inv(mod % x))) % mod;
}
Details
Pretests
Final Tests
Test #1:
score: 0
Wrong Answer
time: 753ms
memory: 394468kb
Test #2:
score: 0
Wrong Answer
time: 744ms
memory: 394520kb
Test #3:
score: 0
Wrong Answer
time: 780ms
memory: 394524kb
Test #4:
score: 0
Wrong Answer
time: 831ms
memory: 394412kb
Test #5:
score: 0
Wrong Answer
time: 813ms
memory: 394528kb