QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#865892#5. 在线 O(1) 逆元snpmrnhlolCompile Error//C++17317b2025-01-22 05:49:522025-01-22 05:49:52

Judging History

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

  • [2025-01-22 05:49:52]
  • 评测
  • [2025-01-22 05:49:52]
  • 提交

answer

#include <bits/stdc++.h>
#include "inv.h"
using namespace std;
int p2;
int fastexp(int a, int b){
    int r = 1;
    while(b){
        if(b&1)r = 1ll*r*a%p2;
        a = 1ll*a*a%p2;
        b/=2;
    }
    return r;
}
void init(int p){
    p2 = p;
}
int inv(int x){
    return fastexp(x, mod - 2);
}

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: In function ‘int inv(int)’:
answer.code:18:23: error: ‘mod’ was not declared in this scope; did you mean ‘modf’?
   18 |     return fastexp(x, mod - 2);
      |                       ^~~
      |                       modf