QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#775491#5. 在线 O(1) 逆元Physics212303Compile Error//C++17233b2024-11-23 16:04:342024-11-23 16:04:35

Judging History

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

  • [2024-11-23 16:04:35]
  • 评测
  • [2024-11-23 16:04:34]
  • 提交

answer

#include "inv.h"
const int N=1e8;
static int P,a[N+1];
void init(int p){
  P=p,a[0]=a[1]=1;
  for(int i=2;i<=N;i++)
    a[i]=P-1ll*(P/i)*a[P%i]%P;
}
int inv(int x){
  if(x<=N)return a[x];
  return p-1ll*(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: In function ‘int inv(int)’:
answer.code:11:10: error: ‘p’ was not declared in this scope
   11 |   return p-1ll*(p/x)*inv(p%x)%p;
      |          ^