QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#298938#5. 在线 O(1) 逆元Untitled_unrevisedCompile Error//C++14323b2024-01-06 16:04:292024-01-06 16:04:30

Judging History

你现在查看的是测评时间为 2024-01-06 16:04:30 的历史记录

  • [2024-11-05 21:57:27]
  • 管理员手动重测本题所有提交记录
  • [2024-01-06 16:04:30]
  • 评测
  • [2024-01-06 16:04:29]
  • 提交

answer

#include <vector>
#include "inv.h"

std::vector<int> invmem;
size_t s;
int P;

void init(int p) {
	s = ((p - 1) >> 3) + 1;
	invmem = std::vector<int>(s);
	P = p;
	invmem[1] = 1;
}

int inv(int x) {
	return (x < s && invmem[x]) ? invmem[x] : (invmem[x] = P - (unsigned long long) (P / x) * inv(P % x) % P);
}

詳細信息

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:5:1: error: ‘size_t’ does not name a type
    5 | size_t s;
      | ^~~~~~
answer.code:3:1: note: ‘size_t’ is defined in header ‘<cstddef>’; did you forget to ‘#include <cstddef>’?
    2 | #include "inv.h"
  +++ |+#include <cstddef>
    3 | 
answer.code: In function ‘void init(int)’:
answer.code:9:9: error: ‘s’ was not declared in this scope
    9 |         s = ((p - 1) >> 3) + 1;
      |         ^
answer.code: In function ‘int inv(int)’:
answer.code:16:21: error: ‘s’ was not declared in this scope
   16 |         return (x < s && invmem[x]) ? invmem[x] : (invmem[x] = P - (unsigned long long) (P / x) * inv(P % x) % P);
      |                     ^