QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#94784 | #5. 在线 O(1) 逆元 | skc | 100 ✓ | 2206ms | 27600kb | C++14 | 783b | 2023-04-07 19:03:20 | 2024-11-05 21:47:58 |
Judging History
你现在查看的是最新测评结果
- [2023-08-10 23:21:45]
- System Update: QOJ starts to keep a history of the judgings of all the submissions.
- [2023-04-07 19:03:20]
- 提交
answer
#include<bits/stdc++.h>
using namespace std;
constexpr int mod=998244353,mod1=974849;
struct _{
int p,q,t;
}a[mod1];
int inv_[3<<20],inv1[1<<10];
int inv(int x){
int a=x>>10,r=x&1023;
int c=1024*::a[a].p+r*::a[a].q+1023*::a[a].t;
bool flag=0;
if(c<0) c=-c,flag=1;
int rv=(long long)::a[a].q*inv_[c]%mod;
if(rv&&flag) rv=mod-rv;
return rv;
}
void init(int){
int i,j,S=sqrt(mod1)+1;
for(i=1;i<=S;++i){
if(i==1) inv1[i]=1;
else inv1[i]=(long long)(mod1-mod1/i)*inv1[mod1%i]%mod1;
for(j=0;j<=S;++j){
int tmp=(long long)j*inv1[i]%mod1;
a[tmp]={j,i};
if(tmp) a[mod1-tmp]={-j,i};
}
}
for(i=0;i<mod1;++i) a[i].t=((long long)i*a[i].q-a[i].p)/mod1;
inv_[1]=1;
for(i=2;i<3<<20;++i) inv_[i]=(long long)(mod-mod/i)*inv_[mod%i]%mod;
}
詳細信息
Pretests
Final Tests
Test #1:
score: 10
Accepted
time: 24ms
memory: 27600kb
Test #2:
score: 20
Accepted
time: 240ms
memory: 27544kb
Test #3:
score: 30
Accepted
time: 1101ms
memory: 27452kb
Test #4:
score: 20
Accepted
time: 1765ms
memory: 27412kb
Test #5:
score: 20
Accepted
time: 2206ms
memory: 27416kb