QOJ.ac

QOJ

Time Limit: 1 s Memory Limit: 1024 MB Total points: 100

#4819. Just Another Number Theory Problem

الإحصائيات

给定 $n$ 个质数 $1 < p_1 < p_2 < \dots < p_n < 10^{18}$,其中 $p_1 \le 100$。如果一个数 $x$ 能被至少一个 $p_i$ 整除,则称该数为“好数”。

取区间 $[0, p_1 \cdot p_2 \cdot \dots \cdot p_n]$ 内所有的好数 $a_1, a_2, \dots, a_m$,并将它们按升序排列($a_1 < a_2 < \dots < a_m$)。你的任务是计算 $\sum_{i=1}^{m-1} (a_{i+1} - a_i)^2$。由于结果可能非常大,请输出其对 $998\,244\,353$ 取模的结果。

输入格式

第一行包含一个整数 $n$ ($1 \le n \le 10^5$)。

第二行包含 $n$ 个整数 $p_1, p_2, \dots, p_n$ ($1 < p_1 < p_2 < \dots < p_n < 10^{18}$)。保证 $2 \le p_1 < 100$,且每个 $p_i$ ($1 \le i \le n$) 均为质数。

输出格式

输出一行,包含一个整数,表示答案对 $998\,244\,353$ 取模的结果。

样例

样例输入 1

2
2 5

样例输出 1

18

样例输入 2

3
5 7 233

样例输出 2

31275

说明

在第一个样例中,好数列表为:

  • $a_1 = 0$
  • $a_2 = 2$
  • $a_3 = 4$
  • $a_4 = 5$
  • $a_5 = 6$
  • $a_6 = 8$
  • $a_7 = 10$

因此,答案为 $(2 - 0)^2 + (4 - 2)^2 + (5 - 4)^2 + (6 - 5)^2 + (8 - 6)^2 + (10 - 8)^2 = 18$。

Discussions

About Discussions

The discussion section is only for posting: 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.
  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.