QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#241456 | #5. 在线 O(1) 逆元 | mfeitveer | 10 | 115ms | 42288kb | C++14 | 395b | 2023-11-06 07:52:36 | 2024-11-05 21:54:25 |
Judging History
answer
#include "inv.h"
#include <unordered_map>
using namespace std;
const int N = 10000010;
const int mod = 998244353;
typedef long long ll;
unordered_map<int, int> mp;
ll Inv[N];
ll ask(ll x)
{
if(mp.find(x) != mp.end()) return mp[x];
return mp[x] = (mod - mod / x) * ask(mod % x) % mod;
}
void init(int p)
{
mp[1] = 1;
}
int inv(int x)
{
return ask(x);
}
Details
Pretests
Final Tests
Test #1:
score: 10
Accepted
time: 115ms
memory: 42288kb
Test #2:
score: 0
Time Limit Exceeded
Test #3:
score: 0
Time Limit Exceeded
Test #4:
score: 0
Time Limit Exceeded
Test #5:
score: 0
Time Limit Exceeded