QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#268022#5. 在线 O(1) 逆元David71370 984ms161636kbC++14404b2023-11-27 22:55:472023-11-27 22:55:49

Judging History

This is a historical verdict posted at 2023-11-27 22:55:49.

  • [2024-11-05 21:55:40]
  • 管理员手动重测本题所有提交记录
  • Verdict: 80
  • Time: 5160ms
  • Memory: 161428kb
  • [2023-11-27 22:55:49]
  • Judged
  • Verdict: 70
  • Time: 984ms
  • Memory: 161636kb
  • [2023-11-27 22:55:47]
  • Submitted

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

Test #1:

score: 30
Accepted
time: 363ms
memory: 161636kb

Test #2:

score: 40
Accepted
time: 984ms
memory: 160556kb

Test #3:

score: 0
Time Limit Exceeded