QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#480139#5. 在线 O(1) 逆元Williamxzh#Compile Error//C++20867b2024-07-16 08:42:352024-11-05 22:00:46

Judging History

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

  • [2024-11-05 22:00:46]
  • 管理员手动重测本题所有提交记录
  • [2024-07-16 08:42:35]
  • 评测
  • [2024-07-16 08:42:35]
  • 提交

answer

#include <bits/stdc++.h>
#include "inv.h"
#define il inline
#define B __int128
using namespace std;
typedef long long ll;
const int mod=998244353;
il ll qp(ll a,ll b){
	ll ans=1ll;
	while(b){
		if(b&1) ans=(ans*a)%mod;
		a=(a*a)%mod,b>>=1;
	}return ans;
}
const ll N=1e7+5;
int n,fac[N],iv[N],a[N];
il void init(int MOD){
	n=N-5,fac[0]=1ll;for(int i=1;i<=n;++i) fac[i]=(1ll*fac[i-1]*i)%mod;
	iv[n]=qp(fac[n],mod-2ll);for(int i=n-1;i>=0;--i) iv[i]=(iv[i+1]*(i+1ll))%mod;
	for(int i=1;i<=n;++i) a[i]=(1ll*fac[i-1]*iv[i])%mod;
}
int inv(int x){
	if(x<=n) return a[x];
	int y=mod/x;
	return 1ll*(mod-y)*inv(mod-x*y)%mod;
}
/*int main(){
	init(mod);
	mt19937 rnd(time(0));
	for(int i=1;i<=100;++i){
		int x=rnd()%(mod-1)+1;
		//if(inv(x)!=qp(x,mod-2ll)) printf("%d %d %d\n",x,inv(x),qp(x,mod-2ll));
		//else puts("*");
	}
	return 0;
} */

详细

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/ccSoyCX4.o: in function `main':
implementer.cpp:(.text.startup+0x12b): undefined reference to `init(int)'
collect2: error: ld returned 1 exit status