QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#624677#5. 在线 O(1) 逆元dww_1337Compile Error//C++14224b2024-10-09 16:24:312024-11-05 22:04:27

Judging History

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

  • [2024-11-05 22:04:27]
  • 管理员手动重测本题所有提交记录
  • [2024-10-09 16:24:31]
  • 评测
  • [2024-10-09 16:24:31]
  • 提交

answer

#include "inv.h"

const int MAXN = 1e8 + 7;
int inv[MAXN];

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

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

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:4:13: error: ‘int inv [100000007]’ redeclared as different kind of entity
    4 | int inv[MAXN];
      |             ^
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:8:14: warning: pointer to a function used in arithmetic [-Wpointer-arith]
    8 |         inv[1] = 1;
      |              ^
answer.code:8:16: error: assignment of read-only location ‘*(inv + 1)’
    8 |         inv[1] = 1;
      |         ~~~~~~~^~~
answer.code:9:47: warning: pointer to a function used in arithmetic [-Wpointer-arith]
    9 |         for(int i = 1 ; i <= MAXN ; i++) inv[i] = long long(p - p / i) * inv[p % i] % p
      |                                               ^
answer.code:9:51: error: expected primary-expression before ‘long’
    9 |         for(int i = 1 ; i <= MAXN ; i++) inv[i] = long long(p - p / i) * inv[p % i] % p
      |                                                   ^~~~
answer.code: In function ‘int inv(int)’:
answer.code:14:21: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   14 |         return inv[x];
      |                     ^
answer.code:14:21: error: invalid conversion from ‘int (*)(int)’ to ‘int’ [-fpermissive]
   14 |         return inv[x];
      |                     ^
      |                     |
      |                     int (*)(int)