QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#705445#5. 在线 O(1) 逆元lvliang0 0ms0kbC++14560b2024-11-02 23:30:252024-11-02 23:30:27

Judging History

This is a historical verdict posted at 2024-11-02 23:30:27.

  • [2024-11-05 22:07:59]
  • 管理员手动重测本题所有提交记录
  • Verdict: 0
  • Time: 0ms
  • Memory: 0kb
  • [2024-11-02 23:30:27]
  • Judged
  • Verdict: 0
  • Time: 0ms
  • Memory: 0kb
  • [2024-11-02 23:30:25]
  • Submitted

answer

#include "inv.h"
#include <vector>
#include <iostream>
const int N = 1e7 + 10;
std::vector<int> vec(N);
int quickPow(int base, int power, int mod) {
    int result = 1;
    base = base % mod;
    while (power > 0) {
        if (power & 1) {
            result = (result * base) % mod;
        }
        base = (base * base) % mod;
        power >>= 1;
    }
    return result;
}
void init(int p) {
    vec[1] = 1;
    for (int i = 2; i < N; i++) {
        vec[i] = quickPow(i, p - 2, p);
    }
}

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

Details


Pretests


Final Tests

Test #1:

score: 0
Runtime Error

Test #2:

score: 0
Runtime Error

Test #3:

score: 0
Runtime Error