QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#134753#5. 在线 O(1) 逆元sserxhsCompile Error//C++20936b2023-08-04 20:44:122023-08-04 20:44:16

Judging History

你现在查看的是测评时间为 2023-08-04 20:44:16 的历史记录

  • [2024-11-05 21:51:06]
  • 管理员手动重测本题所有提交记录
  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-08-04 20:44:16]
  • 评测
  • [2023-08-04 20:44:12]
  • 提交

answer

#include "bits/stdc++.h"
using namespace std;
namespace online_inv
{
	typedef unsigned int ui;
	typedef unsigned long long ll;
	const ui p=998244353;
	const ui n=1010,m=n*n,N=m+2;
	int l[N],r[N];
	ui y[N];
	bool s[N];
	ui _inv[N*2],i,j,k;
	void init_inv()
	{
		assert(n*n*n>p);
		_inv[1]=1;
		for (i=2; i<m*2; i++)
		{
			j=p/i;
			_inv[i]=(ll)(p-j)*_inv[p-i*j]%p;
		}
		s[0]=y[0]=1;
		for (i=1; i<n; i++) for (j=i; j<n; j++) if (!s[k=i*m/j])
		{
			y[k]=j;
			s[k]=1;
		}
		l[0]=1;
		for (i=1; i<=m; i++) l[i]=s[i]?y[i]:l[i-1];
		r[m]=1;
		for (i=m-1; ~i; i--) r[i]=s[i]?y[i]:r[i+1];
		for (i=0; i<=m; i++) y[i]=min(l[i],r[i]);
	}
	inline ui inv(const ui &x)
	{
		assert(x&&x<p);
		if (x<m*2) return _inv[x];
		k=(ll)x*m/p;
		j=(ll)y[k]*x%p;
		return (j<m*2?_inv[j]:p-_inv[p-j])*(ll)y[k]%p;
	}
}
using online_inv::init_inv,online_inv::inv,online_inv::p;
void init(int p)
{
	init_inv();
}

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);
      |         ~~~~~^~~~~~~~~~
/usr/bin/ld: /tmp/ccUJYFJA.o: in function `main':
implementer.cpp:(.text.startup+0x1f8): undefined reference to `inv(int)'
collect2: error: ld returned 1 exit status