QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#209306#5. 在线 O(1) 逆元fstqwq0 5ms7808kbC++14365b2023-10-10 13:50:352024-11-05 21:53:12

Judging History

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

  • [2024-11-05 21:53:12]
  • 管理员手动重测本题所有提交记录
  • 测评结果:0
  • 用时:5ms
  • 内存:7808kb
  • [2023-10-10 13:50:36]
  • 评测
  • 测评结果:0
  • 用时:5ms
  • 内存:7512kb
  • [2023-10-10 13:50:35]
  • 提交

answer

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

int a[pre];

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

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

Details


Pretests


Final Tests

Test #1:

score: 0
Wrong Answer
time: 2ms
memory: 7808kb

Test #2:

score: 0
Wrong Answer
time: 5ms
memory: 7668kb

Test #3:

score: 0
Wrong Answer
time: 5ms
memory: 7796kb

Test #4:

score: 0
Wrong Answer
time: 5ms
memory: 7800kb

Test #5:

score: 0
Wrong Answer
time: 0ms
memory: 7740kb