QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#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);
}
詳細信息
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