QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#209321#5. 在线 O(1) 逆元fstqwq60 3899ms23440kbC++14443b2023-10-10 13:55:012024-11-05 21:53:38

Judging History

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

  • [2024-11-05 21:53:38]
  • 管理员手动重测本题所有提交记录
  • 测评结果:60
  • 用时:3899ms
  • 内存:23440kb
  • [2023-10-10 13:55:03]
  • 评测
  • 测评结果:70
  • 用时:726ms
  • 内存:23316kb
  • [2023-10-10 13:55:01]
  • 提交

answer

#pragma GCC optimize("Ofast,unroll-loops")

const int mod = 998244353;
const int pre = 5e6;

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) {
	if (x < pre) return a[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


Pretests


Final Tests

Test #1:

score: 10
Accepted
time: 33ms
memory: 23372kb

Test #2:

score: 20
Accepted
time: 787ms
memory: 23440kb

Test #3:

score: 30
Accepted
time: 3899ms
memory: 23424kb

Test #4:

score: 0
Time Limit Exceeded

Test #5:

score: 0
Time Limit Exceeded