QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#241460#5. 在线 O(1) 逆元mfeitveer0 0ms0kbC++14727b2023-11-06 07:59:592023-11-06 08:00:00

Judging History

This is a historical verdict posted at 2023-11-06 08:00:00.

  • [2024-11-05 21:54:28]
  • 管理员手动重测本题所有提交记录
  • Verdict: 0
  • Time: 0ms
  • Memory: 0kb
  • [2023-11-06 08:00:00]
  • Judged
  • Verdict: 0
  • Time: 0ms
  • Memory: 0kb
  • [2023-11-06 07:59:59]
  • Submitted

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 % M;
		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 % M;
		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);
}

详细

Test #1:

score: 0
Memory Limit Exceeded

Test #2:

score: 0
Memory Limit Exceeded

Test #3:

score: 0
Time Limit Exceeded