QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#624772#5. 在线 O(1) 逆元BlackPandaCompile Error//C++14211b2024-10-09 16:35:592024-10-09 16:36:03

Judging History

你现在查看的是测评时间为 2024-10-09 16:36:03 的历史记录

  • [2024-11-05 22:04:45]
  • 管理员手动重测本题所有提交记录
  • [2024-10-09 16:36:03]
  • 评测
  • [2024-10-09 16:35:59]
  • 提交

answer

#include "inv.h"

int inv[100000001];

void init(int p)
{
	inv[1] = 1;
	for (int i = 2; i <= 100000000; i ++ )
	{
		inv[i] = (p - p / i) * inv[p % i] % p;
	}
}

int inv(int x)
{
	return inv[x];
}

详细

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:3:18: error: ‘int inv [100000001]’ redeclared as different kind of entity
    3 | int inv[100000001];
      |                  ^
In file included from answer.code:1:
inv.h:2:5: note: previous declaration ‘int inv(int)’
    2 | int inv(int n);
      |     ^~~
answer.code: In function ‘void init(int)’:
answer.code:7:14: warning: pointer to a function used in arithmetic [-Wpointer-arith]
    7 |         inv[1] = 1;
      |              ^
answer.code:7:16: error: assignment of read-only location ‘*(inv + 1)’
    7 |         inv[1] = 1;
      |         ~~~~~~~^~~
answer.code:10:22: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   10 |                 inv[i] = (p - p / i) * inv[p % i] % p;
      |                      ^
answer.code:10:49: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   10 |                 inv[i] = (p - p / i) * inv[p % i] % p;
      |                                                 ^
answer.code:10:38: error: invalid operands of types ‘int’ and ‘int(int)’ to binary ‘operator*’
   10 |                 inv[i] = (p - p / i) * inv[p % i] % p;
      |                          ~~~~~~~~~~~ ^ ~~~~~~~~~~
      |                             |                   |
      |                             int                 int(int)
answer.code: In function ‘int inv(int)’:
answer.code:16:21: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   16 |         return inv[x];
      |                     ^
answer.code:16:21: error: invalid conversion from ‘int (*)(int)’ to ‘int’ [-fpermissive]
   16 |         return inv[x];
      |                     ^
      |                     |
      |                     int (*)(int)