QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#241450#5. 在线 O(1) 逆元mfeitveerCompile Error//C++14356b2023-11-06 07:49:592023-11-06 07:50:00

Judging History

你现在查看的是测评时间为 2023-11-06 07:50:00 的历史记录

  • [2024-11-05 21:54:24]
  • 管理员手动重测本题所有提交记录
  • [2023-11-06 07:50:00]
  • 评测
  • [2023-11-06 07:49:59]
  • 提交

answer

#include "inv.h"
#include <map>

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

typedef long long ll;

std::unordered_map<int, int> mp;

ll Inv[N];

ll ask(ll x)
{
    if(mp.find(x)) 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

implementer.cpp: In function ‘int main()’:
implementer.cpp:22:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   22 |         scanf("%d", &n);
      |         ~~~~~^~~~~~~~~~
answer.code:9:6: error: ‘unordered_map’ in namespace ‘std’ does not name a template type
    9 | std::unordered_map<int, int> mp;
      |      ^~~~~~~~~~~~~
answer.code:3:1: note: ‘std::unordered_map’ is defined in header ‘<unordered_map>’; did you forget to ‘#include <unordered_map>’?
    2 | #include <map>
  +++ |+#include <unordered_map>
    3 | 
answer.code: In function ‘ll ask(ll)’:
answer.code:15:8: error: ‘mp’ was not declared in this scope
   15 |     if(mp.find(x)) return mp[x];
      |        ^~
answer.code:16:12: error: ‘mp’ was not declared in this scope
   16 |     return mp[x] = (mod - mod / x) * ask(mod % x) % mod;
      |            ^~
answer.code: In function ‘void init(int)’:
answer.code:21:9: error: ‘mp’ was not declared in this scope; did you mean ‘p’?
   21 |         mp[1] = 1;
      |         ^~
      |         p