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

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

  • [2024-11-05 21:54:25]
  • 管理员手动重测本题所有提交记录
  • 测评结果:10
  • 用时:115ms
  • 内存:42288kb
  • [2023-11-06 07:52:37]
  • 评测
  • 测评结果:30
  • 用时:150ms
  • 内存:42180kb
  • [2023-11-06 07:52:36]
  • 提交

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