QOJ.ac

QOJ

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

#1516. Power

Statistics

题目描述

对于输入的质数 $P$,我们定义 $S(x)$ 为长度为 $P$ 的序列 $\{x^0\bmod P, x^1\bmod P \cdots x^{P-1}\bmod P\}$,定义 $T(x)$ 为 $S(x)$ 的前缀最大值序列,即 $T(x)[p]=\max_{i=1}^p S(x)[i]$。

给定 $T$ 组数据,对于每组数据输入 $x$,你需要求出 $T(x)$ 中的元素之和,不进行取模

例如当 $P=5$,$S(2)=\{1,2,4,3,1\}$,$T(2)=\{1,2,4,4,4\}$,因此 $T(2)$ 中的元素之和为 $15$。

请注意数据生成方式。

输入格式

第一行两个正整数 $P$ 和 $T$,表示模数和数据组数。

接下来 $T$ 行每行一个正整数 $x$,表示一组数据。

输出格式

$T$ 行,每行一个答案。

样例数据

样例输入

233 3
1
3
33

样例输出

233
51426
53224

数据范围

每个子任务包含不超过15个测试点,$T=200$,$P$ 在范围内的质数中独立均匀随机,每个 $x$ 在 $[1,P)$ 中独立均匀随机生成。

Subtask 1(10pts):$P\in [900,1000]$。

Subtask 2(20pts):$P\in [0.9\times 10^7,10^7]$。

Subtask 3(30pts):$P\in [0.9\times 10^8,10^8]$。

Subtask 4(40pts):$P\in [0.9\times 10^9,10^9]$。

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.