QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#640864#5. 在线 O(1) 逆元masterhuang0 87ms42944kbC++20352b2024-10-14 16:34:472024-11-05 22:05:42

Judging History

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

  • [2024-11-05 22:05:42]
  • 管理员手动重测本题所有提交记录
  • 测评结果:0
  • 用时:87ms
  • 内存:42944kb
  • [2024-10-14 16:34:48]
  • 评测
  • 测评结果:0
  • 用时:47ms
  • 内存:42972kb
  • [2024-10-14 16:34:47]
  • 提交

answer

#include "inv.h"
#include<bits/stdc++.h>
using namespace std;
const int N=1e7+5,mod=998244353;
int n=N-5,I[N];
void init(int p)
{
	I[1]=1;
	for(int i=2;i<=n;i++) I[i]=(mod-1ll*(mod/i)*I[mod%i])%mod;
}
int inv(int x)
{
	if(x<=n) return I[x];
	int q=mod/x,r=mod%x;
	if(r<x/2) return mod-1ll*q*inv(r)%mod;
	return 1ll*(q+1)*inv(x-r)%mod;
}

詳細信息


Pretests


Final Tests

Test #1:

score: 0
Wrong Answer
time: 73ms
memory: 42852kb

Test #2:

score: 0
Wrong Answer
time: 87ms
memory: 42944kb

Test #3:

score: 0
Wrong Answer
time: 52ms
memory: 42924kb

Test #4:

score: 0
Wrong Answer
time: 56ms
memory: 42944kb

Test #5:

score: 0
Wrong Answer
time: 58ms
memory: 42688kb