QOJ.ac

QOJ

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

#1516. Power

الإحصائيات

题目描述

对于输入的质数 $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]$。

Discussions

About Discussions

The discussion section is only for posting: Editorials, General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues. Submitting multiple issues may cause your account to be banned.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.