QOJ.ac

QOJ

Time Limit: 3 s Memory Limit: 512 MB Total points: 100 Difficulty: [show] Interactive

#5. Online Multiplicative Inverse Query

统计

这是一道交互题,本题仅支持 C++ 语言。

题目描述

$n$ 次询问,每次询问一个 $x$,求出它取模 $p$ 意义下的逆元 $x^{-1}$。

实现细节

你不需要,也不应该实现 main 函数。你只需要包含头文件 inv.h,并实现以下接口:

void init(int p)
  • 该函数接收一个参数 $p$,表示取模的模数。
  • 该函数会在每个测试点调用 query 前被调用恰好一次。
  • 在评测时,保证 $p = 998\,244\,353$。
int inv(int x)
  • 该函数接受一个参数 $x(0 \leq x < p)$。
  • 该函数需要返回 $x$ 在模 $p$ 意义下的逆元。

交互库将调用 inv 恰好 $n$ 次。

子任务

对于所有数据,$1 \leq n \leq 10^8, p=998244353$

  • Subtask 1(10 Points): $n \leq 10^5$
  • Subtask 2(20 Points): $n \leq 10^7$
  • Subtask 3(30 Points): $n \leq 5 \times 10^7$
  • Subtask 4(20 Points): $n \leq 8 \times 10^7$
  • Subtask 5(20 Points): No additional constraints.
About Issues

We understand that our problem archive is not perfect. If you find any issues with the problem, including the statement, scoring configuration, time/memory limits, test cases, etc.

You may use this form to submit an issue regarding the problem. A problem moderator will review your issue and proceed it properly.

STOP! Before you submit an issue, please READ the following guidelines:

  1. This is not a place to publish a discussion, editorial, or requests to debug your code. Your issue will only be visible by you and problem moderators. Other users will not be able to view or reply your issues.
  2. Do not submit duplicated issues. If you have already submitted one, please wait for an moderator to review it. Submitting multiple issues will not speed up the review process and might cause your account to be banned.
  3. Issues must be filed in English or Chinese only.
  4. Be sure your issue is related to this problem. If you need to submit an issue regarding another problem, contest, category, etc., you should submit it to the corresponding page.

Active Issues 0

No issues in this category.

Closed/Resolved Issues 0

No issues in this category.