QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#268022#5. 在线 O(1) 逆元David71380 5160ms161428kbC++14404b2023-11-27 22:55:472024-11-05 21:55:40

Judging History

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

  • [2024-11-05 21:55:40]
  • 管理员手动重测本题所有提交记录
  • 测评结果:80
  • 用时:5160ms
  • 内存:161428kb
  • [2023-11-27 22:55:49]
  • 评测
  • 测评结果:70
  • 用时:984ms
  • 内存:161636kb
  • [2023-11-27 22:55:47]
  • 提交

answer

#include "inv.h"
#include <bits/stdc++.h>
using namespace std;
const int mod = 998244353, N = 1e8;
typedef long long ll;
int invv[N];
void init(int p)
{
    invv[0] = invv[1] = 1;
    for (int i = 2; i <= 4e7; i++) invv[i] = (1ll * (mod - mod / i) * invv[mod % i]) % mod;
}
int inv(int x)
{
    if (x <= 4e7) return invv[x];
    return (1ll * (mod - mod / x) * (ll)(inv(mod % x))) % mod;
}

Details


Pretests


Final Tests

Test #1:

score: 10
Accepted
time: 361ms
memory: 161032kb

Test #2:

score: 20
Accepted
time: 966ms
memory: 160228kb

Test #3:

score: 30
Accepted
time: 3331ms
memory: 161428kb

Test #4:

score: 20
Accepted
time: 5160ms
memory: 160688kb

Test #5:

score: 0
Time Limit Exceeded