QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#241468#5. 在线 O(1) 逆元mfeitveer100 ✓5977ms396372kbC++14421b2023-11-06 08:14:002024-11-05 21:55:04

Judging History

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

  • [2024-11-05 21:55:04]
  • 管理员手动重测本题所有提交记录
  • 测评结果:100
  • 用时:5977ms
  • 内存:396372kb
  • [2023-11-06 08:14:01]
  • 评测
  • 测评结果:100
  • 用时:5831ms
  • 内存:395536kb
  • [2023-11-06 08:14:00]
  • 提交

answer

#include "inv.h"

const int N = 130000010;
const int mod = 998244353;

typedef long long ll;

int Inv[N];

ll ask(ll x) {
	ll res = 1;
	while(x > 100000000)
		res = res * (mod - mod / x) % mod, x = mod % x;
	return res * Inv[x] % mod;
}

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

int inv(int x) {
	return ask(x);
}

詳細信息


Pretests


Final Tests

Test #1:

score: 10
Accepted
time: 828ms
memory: 394316kb

Test #2:

score: 20
Accepted
time: 1340ms
memory: 394868kb

Test #3:

score: 30
Accepted
time: 3331ms
memory: 396124kb

Test #4:

score: 20
Accepted
time: 4848ms
memory: 396372kb

Test #5:

score: 20
Accepted
time: 5977ms
memory: 394532kb