QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#925613#5. 在线 O(1) 逆元lvliang0 0ms0kbC++14281b2025-03-04 20:32:382025-03-04 20:32:42

Judging History

This is the latest submission verdict.

  • [2025-03-04 20:32:42]
  • Judged
  • Verdict: 0
  • Time: 0ms
  • Memory: 0kb
  • [2025-03-04 20:32:38]
  • Submitted

answer

#include "inv.h"
#include <vector>
#include <iostream>
const int N = 1e7 + 10;
std::vector<int> vec(N);

void init(int p) {
    vec[1] = 1;
    for (int i = 2; i < N; i++) {
         vec[i] = p - p / i * vec[p % i] % 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

Test #4:

score: 0
Runtime Error

Test #5:

score: 0
Runtime Error