QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#106145#5. 在线 O(1) 逆元zhoukangyangCompile Error//C++171.2kb2023-05-16 18:30:412023-05-16 18:30:45

Judging History

你现在查看的是测评时间为 2023-05-16 18:30:45 的历史记录

  • [2024-11-05 21:49:43]
  • 管理员手动重测本题所有提交记录
  • [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:30:45]
  • 评测
  • [2023-05-16 18:30:41]
  • 提交

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 = 1024, buf = 3, mod = 998244353, N = 6.1e6 + 7;
int K, ml[N], iv[N], dis[N];
inline int Inv(int x) {
	return x < N ? iv[x] : (ll) Inv(mod % x) * (mod - mod / x) % mod;
}
inline int inv(int w) {
	int d = w / B;
	return !ml[d] ? Inv(w) : (ll) iv[w * ml[d] - dis[d]] * ml[d] % mod;
} 
void init(int rp) {
	K = mod / B;
	L(fb, 1, B * buf) {
		int cur = 0, Add = fb * B;
		for(int p = 0; p <= K; ) {
			if(cur <= K * buf) {
				ml[p] = fb;
				cur += Add, ++p;
			} else {
				int A = (mod - cur + Add - 1) / Add;
				cur += A * Add, p += A;
			}
			if(cur >= mod) cur -= mod; 
		}
	}
	int count = 0;
	L(i, 1, K) if(ml[i]) dis[i] = (ll) ml[i] * i * B / mod * mod, ++count;
//	cout << 1. * count / K << endl;
	iv[1] = 1;
	L(i, 2, N - 1) iv[i] = (ll) iv[mod % i] * (mod - mod / i) % mod;
}

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