QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#850070 | #5. 在线 O(1) 逆元 | mnbvcxz123 | Compile Error | / | / | C++23 | 556b | 2025-01-09 20:08:47 | 2025-01-09 20:08:47 |
Judging History
answer
#include"inv.h"
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
constexpr int mod=998244353;
map<int,int>mp;
int exp(int a, int w){
int ret=1;
a%=mod;
while(w){
if(w&1)ret=1ll*ret*a%mod;
a=1ll*a*a%mod;
w>>=1;
}
return ret;
}
int inv[100000000];
int lst=1;
void init(int p){
inv[1]=1;
}
int inv(int x){
if(x>=1e8)return exp(x,mod-2);
while(lst<x){
inv[lst]=mod-1ll*(mod/lst)*inv[mod%lst]%mod;
++lst;
}
return inv[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:21:18: error: ‘int inv [100000000]’ redeclared as different kind of entity 21 | int inv[100000000]; | ^ In file included from answer.code:1: inv.h:2:5: note: previous declaration ‘int inv(int)’ 2 | int inv(int n); | ^~~ answer.code: In function ‘void init(int)’: answer.code:26:10: warning: pointer to a function used in arithmetic [-Wpointer-arith] 26 | inv[1]=1; | ^ answer.code:26:11: error: assignment of read-only location ‘*(inv + 1)’ 26 | inv[1]=1; | ~~~~~~^~ answer.code: In function ‘int inv(int)’: answer.code:32:16: warning: pointer to a function used in arithmetic [-Wpointer-arith] 32 | inv[lst]=mod-1ll*(mod/lst)*inv[mod%lst]%mod; | ^ answer.code:32:47: warning: pointer to a function used in arithmetic [-Wpointer-arith] 32 | inv[lst]=mod-1ll*(mod/lst)*inv[mod%lst]%mod; | ^ answer.code:32:35: error: invalid operands of types ‘long long int’ and ‘int(int)’ to binary ‘operator*’ 32 | inv[lst]=mod-1ll*(mod/lst)*inv[mod%lst]%mod; | ~~~~~~~~~~~~~^~~~~~~~~~~~~ | | | | long long int int(int) answer.code:35:17: warning: pointer to a function used in arithmetic [-Wpointer-arith] 35 | return inv[x]; | ^ answer.code:35:17: error: invalid conversion from ‘int (*)(int)’ to ‘int’ [-fpermissive] 35 | return inv[x]; | ^ | | | int (*)(int)