QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#479806#5. 在线 O(1) 逆元NOI_AK_ME#Compile Error//C++23841b2024-07-15 20:57:112024-07-15 20:57:18

Judging History

你现在查看的是测评时间为 2024-07-15 20:57:18 的历史记录

  • [2024-11-05 22:00:41]
  • 管理员手动重测本题所有提交记录
  • [2024-07-15 20:57:18]
  • 评测
  • [2024-07-15 20:57:11]
  • 提交

answer

#pragma once
#pragma GCC optimize("Ofast, unroll-loops")
#include "inv.h"
unsigned a[3035136], g[974849];
unsigned inv(int x) {
	const unsigned p = (unsigned long long) x * g[x >> 10] % 998244353;
	return (unsigned long long) g[x >> 10] * (p < 3035136 ? a[p] : 998244353 - a[998244353 - p]) % 998244353;
}
unsigned getinv(unsigned x) {
    return x == 1 ? 1 : 974849 - (unsigned long long)(974849 / x) * getinv(974849 % x) % 974849;
}
void init(int) {
	for(unsigned i = 987;i;--i) {
		unsigned inv = getinv(i);
		for(unsigned j = 1;j <= 987;++j) {
			g[(unsigned long long) j * inv % 974849] = i;
			g[974849 - (unsigned long long) j * inv % 974849] = 998244353 - i;
		}
	}
	g[0] = a[1] = 1;
	for(unsigned i = 2;i ^ 3035136;++i)
		a[i] = 998244353 - (unsigned long long)(998244353 / i) * a[998244353 % i] % 998244353;
}

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:1:9: warning: #pragma once in main file
    1 | #pragma once
      |         ^~~~
answer.code:2:43: warning: bad option ‘-f unroll-loops’ to pragma ‘optimize’ [-Wpragmas]
    2 | #pragma GCC optimize("Ofast, unroll-loops")
      |                                           ^
In file included from answer.code:3:
inv.h:1:16: warning: bad option ‘-f unroll-loops’ to attribute ‘optimize’ [-Wattributes]
    1 | void init(int p);
      |                ^
inv.h:1:16: warning: bad option ‘-f unroll-loops’ to attribute ‘optimize’ [-Wattributes]
inv.h:2:14: warning: bad option ‘-f unroll-loops’ to attribute ‘optimize’ [-Wattributes]
    2 | int inv(int n);
      |              ^
inv.h:2:14: warning: bad option ‘-f unroll-loops’ to attribute ‘optimize’ [-Wattributes]
answer.code:5:19: warning: bad option ‘-f unroll-loops’ to attribute ‘optimize’ [-Wattributes]
    5 | unsigned inv(int x) {
      |                   ^
answer.code:5:10: error: ambiguating new declaration of ‘unsigned int inv(int)’
    5 | unsigned inv(int x) {
      |          ^~~
inv.h:2:5: note: old declaration ‘int inv(int)’
    2 | int inv(int n);
      |     ^~~
answer.code:9:27: warning: bad option ‘-f unroll-loops’ to attribute ‘optimize’ [-Wattributes]
    9 | unsigned getinv(unsigned x) {
      |                           ^
answer.code:12:14: warning: bad option ‘-f unroll-loops’ to attribute ‘optimize’ [-Wattributes]
   12 | void init(int) {
      |              ^