QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#209310#5. 在线 O(1) 逆元fstqwq70 ✓1345ms394416kbC++14369b2023-10-10 13:52:282023-10-10 13:52:30

Judging History

你现在查看的是测评时间为 2023-10-10 13:52:30 的历史记录

  • [2024-11-05 21:53:14]
  • 管理员手动重测本题所有提交记录
  • 测评结果:100
  • 用时:5273ms
  • 内存:394508kb
  • [2023-10-10 13:52:30]
  • 评测
  • 测评结果:70
  • 用时:1345ms
  • 内存:394416kb
  • [2023-10-10 13:52:28]
  • 提交

answer

const int mod = 998244353;
const int pre = 1e8;

int a[pre];

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

int inv(int x) {
	int ret = 1;
	while (x >= pre) {
		ret = 1ll * ret * (mod - mod / x) % mod;
		x = mod % x;
	}
	ret = 1ll * ret * a[x] % mod;	
	return ret;
}

Details

Test #1:

score: 30
Accepted
time: 713ms
memory: 394196kb

Test #2:

score: 40
Accepted
time: 1345ms
memory: 394416kb

Test #3:

score: 0
Time Limit Exceeded