QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#566558#5. 在线 O(1) 逆元yihang_0130 2437ms3884kbC++20298b2024-09-16 00:30:502024-11-05 22:03:54

Judging History

This is the latest submission verdict.

  • [2024-11-05 22:03:54]
  • 管理员手动重测本题所有提交记录
  • Verdict: 30
  • Time: 2437ms
  • Memory: 3884kb
  • [2024-09-16 00:30:50]
  • Judged
  • Verdict: 70
  • Time: 2443ms
  • Memory: 3788kb
  • [2024-09-16 00:30:50]
  • Submitted

answer

using i64 = long long;

i64 mod;

i64 qpow(i64 a, i64 b) {
    i64 res = 1;
    while(b) {
        if(b&1) res = (res * a) % mod;
        a = (a*a) %mod;
        b >>= 1;
    }

    return res;
}

void init(int p) {
    mod = p;
}

i64 inv(int a) {
    return qpow(a, mod-2);
}

Details


Pretests


Final Tests

Test #1:

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

Test #2:

score: 20
Accepted
time: 2437ms
memory: 3884kb

Test #3:

score: 0
Time Limit Exceeded

Test #4:

score: 0
Time Limit Exceeded

Test #5:

score: 0
Time Limit Exceeded