QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#241454#5. 在线 O(1) 逆元mfeitveerCompile Error//C++14383b2023-11-06 07:52:082023-11-06 07:52:09

Judging History

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

  • [2024-11-05 21:54:25]
  • 管理员手动重测本题所有提交记录
  • [2023-11-06 07:52:09]
  • 评测
  • [2023-11-06 07:52:08]
  • 提交

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)) 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);
}

详细

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: In function ‘ll ask(ll)’:
answer.code:16:15: error: could not convert ‘mp.std::unordered_map<int, int>::find(((std::unordered_map<int, int>::key_type)x))’ from ‘std::unordered_map<int, int>::iterator’ {aka ‘std::__detail::_Insert_base<int, std::pair<const int, int>, std::allocator<std::pair<const int, int> >, std::__detail::_Select1st, std::equal_to<int>, std::hash<int>, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, std::__detail::_Prime_rehash_policy, std::__detail::_Hashtable_traits<false, false, true> >::iterator’} to ‘bool’
   16 |     if(mp.find(x)) return mp[x];
      |        ~~~~~~~^~~
      |               |
      |               std::unordered_map<int, int>::iterator {aka std::__detail::_Insert_base<int, std::pair<const int, int>, std::allocator<std::pair<const int, int> >, std::__detail::_Select1st, std::equal_to<int>, std::hash<int>, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, std::__detail::_Prime_rehash_policy, std::__detail::_Hashtable_traits<false, false, true> >::iterator}