QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#370054 | #5. 在线 O(1) 逆元 | OneWan | Compile Error | / | / | C++20 | 1.4kb | 2024-03-28 21:26:09 | 2024-11-05 21:57:58 |
Judging History
你现在查看的是最新测评结果
- [2024-11-05 21:57:58]
- 管理员手动重测本题所有提交记录
- 测评结果:Compile Error
- 用时:0ms
- 内存:0kb
- [2024-03-28 21:26:10]
- 评测
- 测评结果:Compile Error
- 用时:0ms
- 内存:0kb
- [2024-03-28 21:26:09]
- 提交
answer
#include "inv.h"
#include <bits/stdc++.h>
using namespace std;
const int M = 10;
const int B = 1 << M, T = 1 << (M << 1);
struct Inverse {
int mod;
int f[T + 1], p[T + 1], buf[T * 3 + 3], *I = buf + T;
Inverse(int mod) : mod(mod) {
for (int i = 1 ; i <= B ; i++) {
int s = 0, d = i << 10;
for (int j = 1 ; j <= T ; j++) {
if ((s += d) >= mod) s -= mod;
if (s <= T) {
if (f[j] == 0) {
f[j] = i;
p[j] = s;
}
} else if (s >= mod - T) {
if (f[j] == 0) {
f[j] = i;
p[j] = s - mod;
}
} else {
int t = (mod - T - s - 1) / d;
s += t * d;
j += t;
}
}
}
I[1] = f[0] = 1;
for (int i = 2 ; i <= T << 1 ; i++) {
I[i] = 1LL * (mod - mod / i) * I[mod % i] % mod;
}
for (int i = -1 ; i >= -T ; i--) {
I[i] = mod - I[-i];
}
}
int operator()(int x) {
return 1LL * I[p[x >> M] + (x & ((1 << M) - 1)) * f[x >> M]] * f[x >> M] % mod;
}
}; // Inverse
Inverse invs;
void init(int p) {
invs = Inverse(p);
}
int inv(int x) {
return invs(x);
}
Details
implementer.cpp: In function ‘int main()’: implementer.cpp:22:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 22 | scanf("%d", &n); | ~~~~~^~~~~~~~~~ answer.code:46:9: error: no matching function for call to ‘Inverse::Inverse()’ 46 | Inverse invs; | ^~~~ answer.code:11:5: note: candidate: ‘Inverse::Inverse(int)’ 11 | Inverse(int mod) : mod(mod) { | ^~~~~~~ answer.code:11:5: note: candidate expects 1 argument, 0 provided answer.code:8:8: note: candidate: ‘constexpr Inverse::Inverse(const Inverse&)’ 8 | struct Inverse { | ^~~~~~~ answer.code:8:8: note: candidate expects 1 argument, 0 provided answer.code:8:8: note: candidate: ‘constexpr Inverse::Inverse(Inverse&&)’ answer.code:8:8: note: candidate expects 1 argument, 0 provided