QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#468527#5. 在线 O(1) 逆元yzc35823015110 290ms42384kbC++14302b2024-07-08 21:21:182024-11-05 22:00:02

Judging History

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

  • [2024-11-05 22:00:02]
  • 管理员手动重测本题所有提交记录
  • 测评结果:10
  • 用时:290ms
  • 内存:42384kb
  • [2024-07-08 21:21:19]
  • 评测
  • 测评结果:30
  • 用时:203ms
  • 内存:42448kb
  • [2024-07-08 21:21:18]
  • 提交

answer

#include"inv.h"
#include<unordered_map>
using std::unordered_map;
typedef long long ll;
int MOD;
unordered_map<int,int>Inv;
void init(int p){
	MOD=p,
	Inv[1]=1;
}
int inv(int x){
	if(!x)
		return 0;
	else if(Inv[x])
		return Inv[x];
	else
		return (ll)(MOD-MOD/x)%MOD*inv(MOD%x)%MOD;
}

详细


Pretests


Final Tests

Test #1:

score: 10
Accepted
time: 290ms
memory: 42384kb

Test #2:

score: 0
Time Limit Exceeded

Test #3:

score: 0
Time Limit Exceeded

Test #4:

score: 0
Time Limit Exceeded

Test #5:

score: 0
Time Limit Exceeded