QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#106129#5. 在线 O(1) 逆元zhoukangyangCompile Error//C++17977b2023-05-16 18:08:452024-11-05 21:49:26

Judging History

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

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

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, use[N], inv[N];
inline int Inv(int x) {
	return x < N ? inv[x] : (ll) Inv(mod % x) * (mod - mod / x) % mod;
}
inline int inv(int w) {
	int d = w / B;
	return use[d] ? Inv(w) : (ll) inv[(ll) w * use[d] % mod] * use[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) {
				use[p] = fb;
			}
			cur += fb * B;
			if(cur >= mod) cur -= mod;
		}
	}
	inv[1] = 1;
	L(i, 2, N - 1) inv[i] = (ll) inv[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);
      |         ~~~~~^~~~~~~~~~
answer.code:14:21: error: ‘int inv [6000007]’ redeclared as different kind of entity
   14 | int K, use[N], inv[N];
      |                     ^
In file included from answer.code:2:
inv.h:2:5: note: previous declaration ‘int inv(int)’
    2 | int inv(int n);
      |     ^~~
answer.code: In function ‘int Inv(int)’:
answer.code:16:29: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   16 |         return x < N ? inv[x] : (ll) Inv(mod % x) * (mod - mod / x) % mod;
      |                             ^
answer.code:16:22: error: operands to ‘?:’ have different types ‘int (*)(int)’ and ‘long long int’
   16 |         return x < N ? inv[x] : (ll) Inv(mod % x) * (mod - mod / x) % mod;
      |                ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
answer.code: In function ‘int inv(int)’:
answer.code:20:64: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   20 |         return use[d] ? Inv(w) : (ll) inv[(ll) w * use[d] % mod] * use[d] % mod;
      |                                                                ^
answer.code: In function ‘void init(int)’:
answer.code:34:14: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   34 |         inv[1] = 1;
      |              ^
answer.code:34:16: error: assignment of read-only location ‘*(inv + 1)’
   34 |         inv[1] = 1;
      |         ~~~~~~~^~~
answer.code:35:29: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   35 |         L(i, 2, N - 1) inv[i] = (ll) inv[mod % i] * (mod - mod / i) % mod;
      |                             ^
answer.code:35:49: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   35 |         L(i, 2, N - 1) inv[i] = (ll) inv[mod % i] * (mod - mod / i) % mod;
      |                                                 ^
answer.code:35:31: error: assignment of read-only location ‘*(inv + ((sizetype)i))’
   35 |         L(i, 2, N - 1) inv[i] = (ll) inv[mod % i] * (mod - mod / i) % mod;
      |                        ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~