QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#241449 | #5. 在线 O(1) 逆元 | mfeitveer | 60 | 5935ms | 3876kb | C++14 | 569b | 2023-11-06 07:47:57 | 2024-11-05 21:54:24 |
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;
// }
inline int power(ll x, ll y = mod - 2)
{
ll res = 1;
while(y)
{
if(y & 1) res = res * x % mod;
x = x * x % mod, y /= 2;
}
return res;
}
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 power(x);
}
詳細信息
Pretests
Final Tests
Test #1:
score: 10
Accepted
time: 12ms
memory: 3824kb
Test #2:
score: 20
Accepted
time: 1187ms
memory: 3876kb
Test #3:
score: 30
Accepted
time: 5935ms
memory: 3740kb
Test #4:
score: 0
Time Limit Exceeded
Test #5:
score: 0
Time Limit Exceeded