QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#850075#5. 在线 O(1) 逆元mnbvcxz123Compile Error//C++23564b2025-01-09 20:10:182025-01-09 20:10:18

Judging History

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

  • [2025-01-09 20:10:18]
  • 评测
  • [2025-01-09 20:10:18]
  • 提交

answer

#include"inv.h"
#include<bits/stdc++.h>
using namespace std;
using ll=long long;

constexpr int mod=998244353;

map<int,int>mp;

int exp(int a, int w){
    int ret=1;
    a%=mod;
    while(w){
        if(w&1)ret=1ll*ret*a%mod;
        a=1ll*a*a%mod;
        w>>=1;
    }
    return ret;
}

int inver[100000000];

int lst=1;

void init(int p){
    inv[1]=1;
}

int inv(int x){
    if(x>=1e8)return exp(x,mod-2);
    while(lst<x){
        inver[lst]=mod-1ll*(mod/lst)*inver[mod%lst]%mod;
        ++lst;
    }
    return inver[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: In function ‘void init(int)’:
answer.code:26:10: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   26 |     inv[1]=1;
      |          ^
answer.code:26:11: error: assignment of read-only location ‘*(inv + 1)’
   26 |     inv[1]=1;
      |     ~~~~~~^~