QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#241457#5. 在线 O(1) 逆元mfeitveerCompile Error//C++14751b2023-11-06 07:58:322024-11-05 21:54:25

Judging History

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

  • [2024-11-05 21:54:25]
  • 管理员手动重测本题所有提交记录
  • [2023-11-06 07:58:32]
  • 评测
  • [2023-11-06 07:58:32]
  • 提交

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) const
	{
		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 Inv[N];

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

Details

implementer.cpp: In function ‘int main()’:
implementer.cpp:22:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   22 |         scanf("%d", &n);
      |         ~~~~~^~~~~~~~~~
answer.code: In member function ‘int& HashMap::operator[](const int&) const’:
answer.code:15:51: error: binding reference of type ‘int&’ to ‘const int’ discards qualifiers
   15 |                         if(a[i] == tmp) return v[i];
      |                                                ~~~^
answer.code:16:23: error: increment of member ‘HashMap::ct’ in read-only object
   16 |                 nxt[++ct] = head[x], head[x] = ct;
      |                       ^~
answer.code:16:27: error: assignment of read-only location ‘((const HashMap*)this)->HashMap::nxt[((int)(++((const HashMap*)this)->HashMap::ct))]’
   16 |                 nxt[++ct] = head[x], head[x] = ct;
      |                 ~~~~~~~~~~^~~~~~~~~
answer.code:16:46: error: assignment of read-only location ‘((const HashMap*)this)->HashMap::head[x]’
   16 |                 nxt[++ct] = head[x], head[x] = ct;
      |                                      ~~~~~~~~^~~~
answer.code:17:23: error: assignment of read-only location ‘((const HashMap*)this)->HashMap::a[((int)((const HashMap*)this)->HashMap::ct)]’
   17 |                 a[ct] = tmp; return v[ct];
      |                 ~~~~~~^~~~~
answer.code:17:41: error: binding reference of type ‘int&’ to ‘const int’ discards qualifiers
   17 |                 a[ct] = tmp; return v[ct];
      |                                     ~~~~^
answer.code: At global scope:
answer.code:28:8: error: ‘N’ was not declared in this scope
   28 | ll Inv[N];
      |        ^