QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#106135#5. 在线 O(1) 逆元zhoukangyang100 ✓4823ms33092kbC++17953b2023-05-16 18:15:462024-11-05 21:49:34

Judging History

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

  • [2024-11-05 21:49:34]
  • 管理员手动重测本题所有提交记录
  • 测评结果:100
  • 用时:4823ms
  • 内存:33092kb
  • [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:15:48]
  • 评测
  • 测评结果:70
  • 用时:3414ms
  • 内存:31356kb
  • [2023-05-16 18:15:46]
  • 提交

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

詳細信息


Pretests


Final Tests

Test #1:

score: 10
Accepted
time: 2681ms
memory: 31204kb

Test #2:

score: 20
Accepted
time: 2902ms
memory: 32028kb

Test #3:

score: 30
Accepted
time: 3721ms
memory: 31528kb

Test #4:

score: 20
Accepted
time: 4391ms
memory: 33092kb

Test #5:

score: 20
Accepted
time: 4823ms
memory: 31524kb