QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#241458#5. 在线 O(1) 逆元mfeitveer0 0ms0kbC++14731b2023-11-06 07:59:102024-11-05 21:54:26

Judging History

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

  • [2024-11-05 21:54:26]
  • 管理员手动重测本题所有提交记录
  • 测评结果:0
  • 用时:0ms
  • 内存:0kb
  • [2023-11-06 07:59:11]
  • 评测
  • 测评结果:0
  • 用时:0ms
  • 内存:0kb
  • [2023-11-06 07:59:10]
  • 提交

answer

#include "inv.h"

const int M = 133834517;
const int mod = 998244353;

typedef long long ll;

struct HashMap
{
	int ct, a[M], v[M], nxt[M], head[M];
	inline int &operator[](const int &tmp)
	{
		int x = 19260817ll * tmp % mod;
		for(int i = head[x];i;i = nxt[i])
			if(a[i] == tmp) return v[i];
		nxt[++ct] = head[x], head[x] = ct;
		a[ct] = tmp; return v[ct];
	}
	inline bool find(int tmp)
	{
		int x = 19260817ll * tmp % mod;
		for(int i = head[x];i;i = nxt[i])
			if(a[i] == tmp) return 1;
		return 0;
	}
} mp;

ll ask(ll x)
{
    if(mp.find(x)) return mp[x];
    return mp[x] = (mod - mod / x) * ask(mod % x) % mod;
}

void init(int p)
{
	mp[1] = 1;
}

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

詳細信息


Pretests


Final Tests

Test #1:

score: 0
Runtime Error

Test #2:

score: 0
Runtime Error

Test #3:

score: 0
Runtime Error

Test #4:

score: 0
Runtime Error

Test #5:

score: 0
Runtime Error