QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#840201 | #5. 在线 O(1) 逆元 | Graygoo | Compile Error | / | / | C++14 | 743b | 2025-01-02 16:17:17 | 2025-01-02 16:17:23 |
Judging History
answer
#include<bits/stdc++.h>
#include"inv.h"
using namespace std;
#define ll long long
const ll mod = 998244353;
const ll magic = 68996401;
ll magic_inv;
int prime[]={2,3,5,7,11};
ll iv[10000005];
ll qpow(ll a,int w){
ll ans=1;
while(w){
if(w&1)ans=ans*a%mod;
w>>=1;a=a*a%mod;
}
return ans;
}
void init(int p){
iv[1]=1;
for(int i=2;i<=10000000;i++)iv[i]=(mod-iv[mod%i]*(mod/i)%mod)%mod;
magic_inv=qpow(magic,mod-2);
return ;
}
ll inv(int x){
ll ans=magic_inv;x=x*magic%mod;
for(int i=0;i<5;i++){
while(x%prime[i]==0)ans=ans*iv[prime[i]]%mod,x/=prime[i];
}
if(x<=10000000)ans=ans*iv[x]%mod;
else ans=ans*qpow(x,mod-2)%mod;
return ans;
}
詳細信息
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:24:4: error: ambiguating new declaration of ‘long long int inv(int)’ 24 | ll inv(int x){ | ^~~ In file included from answer.code:2: inv.h:2:5: note: old declaration ‘int inv(int)’ 2 | int inv(int n); | ^~~