QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#865893#5. 在线 O(1) 逆元snpmrnhlol30 2551ms3840kbC++17316b2025-01-22 05:51:032025-01-22 05:51:05

Judging History

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

  • [2025-01-22 05:51:05]
  • 评测
  • 测评结果:30
  • 用时:2551ms
  • 内存:3840kb
  • [2025-01-22 05:51:03]
  • 提交

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, p2 - 2);
}

Details


Pretests


Final Tests

Test #1:

score: 10
Accepted
time: 25ms
memory: 3840kb

Test #2:

score: 20
Accepted
time: 2551ms
memory: 3840kb

Test #3:

score: 0
Time Limit Exceeded

Test #4:

score: 0
Time Limit Exceeded

Test #5:

score: 0
Time Limit Exceeded