QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#241449#5. 在线 O(1) 逆元mfeitveer70 1230ms3744kbC++14569b2023-11-06 07:47:572023-11-06 07:47:57

Judging History

你现在查看的是测评时间为 2023-11-06 07:47:57 的历史记录

  • [2024-11-05 21:54:24]
  • 管理员手动重测本题所有提交记录
  • 测评结果:60
  • 用时:5935ms
  • 内存:3876kb
  • [2023-11-06 07:47:57]
  • 评测
  • 测评结果:70
  • 用时:1230ms
  • 内存:3744kb
  • [2023-11-06 07:47:57]
  • 提交

answer

#include "inv.h"

const int N = 10000010;
const int mod = 998244353;

typedef long long ll;

ll Inv[N];

// ll ask(ll x)
// {
//     if(x <= 10000000) return Inv[x];
//     return (mod - mod / x) * ask(mod % x) % mod;
// }

inline int power(ll x, ll y = mod - 2)
{
	ll res = 1;
	while(y)
	{
		if(y & 1) res = res * x % mod;
		x = x * x % mod, y /= 2;
	}
	return res;
}

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

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

Details

Test #1:

score: 30
Accepted
time: 13ms
memory: 3516kb

Test #2:

score: 40
Accepted
time: 1230ms
memory: 3744kb

Test #3:

score: 0
Time Limit Exceeded