QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#241456#5. 在线 O(1) 逆元mfeitveer10 115ms42288kbC++14395b2023-11-06 07:52:362024-11-05 21:54:25

Judging History

This is the latest submission verdict.

  • [2024-11-05 21:54:25]
  • 管理员手动重测本题所有提交记录
  • Verdict: 10
  • Time: 115ms
  • Memory: 42288kb
  • [2023-11-06 07:52:37]
  • Judged
  • Verdict: 30
  • Time: 150ms
  • Memory: 42180kb
  • [2023-11-06 07:52:36]
  • Submitted

answer

#include "inv.h"
#include <unordered_map>
using namespace std;

const int N = 10000010;
const int mod = 998244353;

typedef long long ll;

unordered_map<int, int> mp;

ll Inv[N];

ll ask(ll x)
{
    if(mp.find(x) != mp.end()) return mp[x];
    return mp[x] = (mod - mod / x) * ask(mod % x) % mod;
}

void init(int p)
{
	mp[1] = 1;
}

int inv(int x)
{
	return ask(x);
}

Details


Pretests


Final Tests

Test #1:

score: 10
Accepted
time: 115ms
memory: 42288kb

Test #2:

score: 0
Time Limit Exceeded

Test #3:

score: 0
Time Limit Exceeded

Test #4:

score: 0
Time Limit Exceeded

Test #5:

score: 0
Time Limit Exceeded