QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#640621#5. 在线 O(1) 逆元Yu_mx30 2201ms3880kbC++14221b2024-10-14 14:49:392024-11-05 22:05:21

Judging History

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

  • [2024-11-05 22:05:21]
  • 管理员手动重测本题所有提交记录
  • 测评结果:30
  • 用时:2201ms
  • 内存:3880kb
  • [2024-10-14 14:49:40]
  • 评测
  • 测评结果:70
  • 用时:2185ms
  • 内存:3788kb
  • [2024-10-14 14:49:39]
  • 提交

answer

#include"inv.h"

int mod;

void init(int p){
	mod = p;
}

int inv(int x){
	int p = mod;
	int k = p-2;
	int res = 1%p;
	while(k){
		if(k&1) res = 1LL*res*x%p;
		k >>= 1;
		x = 1LL*x*x%p;
	}
	return res;
}

詳細信息


Pretests


Final Tests

Test #1:

score: 10
Accepted
time: 22ms
memory: 3732kb

Test #2:

score: 20
Accepted
time: 2201ms
memory: 3880kb

Test #3:

score: 0
Time Limit Exceeded

Test #4:

score: 0
Time Limit Exceeded

Test #5:

score: 0
Time Limit Exceeded