QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#310623#5. 在线 O(1) 逆元KiharaTouma100 ✓5159ms394508kbC++14310b2024-01-21 16:21:202024-11-05 21:57:29

Judging History

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

  • [2024-11-05 21:57:29]
  • 管理员手动重测本题所有提交记录
  • 测评结果:100
  • 用时:5159ms
  • 内存:394508kb
  • [2024-01-21 16:21:21]
  • 评测
  • 测评结果:100
  • 用时:5487ms
  • 内存:394488kb
  • [2024-01-21 16:21:20]
  • 提交

answer

//qoj5
#include "inv.h"

const int P = 998244353;
const int N = 1e8 + 5;
int a[N];

void init(int p){
	a[1] = 1;
	for(int i = 2; i < N; ++ i){
		a[i] = P - 1ll * (P / i) * a[P%i] % P;
	}
}

int inv(int x){
	if(x < N){
		return a[x];
	} else {
		return P - 1ll * (P / x) * inv(P%x) % P;
	}
}

Details


Pretests


Final Tests

Test #1:

score: 10
Accepted
time: 596ms
memory: 394452kb

Test #2:

score: 20
Accepted
time: 1062ms
memory: 394340kb

Test #3:

score: 30
Accepted
time: 2906ms
memory: 394508kb

Test #4:

score: 20
Accepted
time: 4245ms
memory: 394396kb

Test #5:

score: 20
Accepted
time: 5159ms
memory: 394324kb