QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#94784#5. 在线 O(1) 逆元skc100 ✓2206ms27600kbC++14783b2023-04-07 19:03:202024-11-05 21:47:58

Judging History

你现在查看的是最新测评结果

  • [2024-11-05 21:47:58]
  • 管理员手动重测本题所有提交记录
  • 测评结果:100
  • 用时:2206ms
  • 内存:27600kb
  • [2024-11-05 21:43:44]
  • 管理员手动重测本题所有提交记录
  • 测评结果:100
  • 用时:2220ms
  • 内存:27592kb
  • [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:22]
  • 评测
  • 测评结果:100
  • 用时:5435ms
  • 内存:27188kb
  • [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