QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#705445#5. 在线 O(1) 逆元lvliang0 0ms0kbC++14560b2024-11-02 23:30:252024-11-05 22:07:59

Judging History

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

  • [2024-11-05 22:07:59]
  • 管理员手动重测本题所有提交记录
  • 测评结果:0
  • 用时:0ms
  • 内存:0kb
  • [2024-11-02 23:30:27]
  • 评测
  • 测评结果:0
  • 用时:0ms
  • 内存:0kb
  • [2024-11-02 23:30:25]
  • 提交

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];
}

詳細信息


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