QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#106134#5. 在线 O(1) 逆元zhoukangyangCompile Error//C++171000b2023-05-16 18:14:012024-11-05 21:49:31

Judging History

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

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

answer

#include<bits/stdc++.h>
#include "inv.h"
#define L(i, j, k) for(int i = (j); i <= (k); ++i)
#define R(i, j, k) for(int i = (j); i >= (k); --i)
#define ll long long 
#define vi vector < int > 
#define sz(a) ((int) (a).size())
#define ll long long 
#define ull unsigned long long
#define me(a, x) memset(a, x, sizeof(a)) 
#define eb emplace_back
using namespace std;
const int B = 1e3, buf = 3, moood = 998244353, N = 6e6 + 7;
int K, use[N], iv[N];
inline int Inv(int x) {
	return x < N ? iv[x] : (ll) Inv(moood % x) * (moood - moood / x) % moood;
}
inline int inv(int w) {
	int d = w / B;
	return !use[d] ? Inv(w) : (ll) iv[(ll) w * use[d] % moood] * use[d] % moood;
} 
void init(int rp) {
	K = moood / B;
	L(fb, 1, B * buf) {
		int cur = 0;
		for(int p = 0; p <= K; ++p) {
			if(cur <= K * buf) {
				use[p] = fb;
			}
			cur += fb * B;
			if(cur >= moood) cur -= moood;
		}
	}
	iv[1] = 1;
	L(i, 2, N - 1) iv[i] = (ll) iv[moood % i] * (moood - moood / i) % moood;
}

详细

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