QOJ.ac

QOJ

حد الوقت: 1.5 s حد الذاكرة: 256 MB مجموع النقاط: 100

#3534. 模数相等的区间

الإحصائيات

给定一个包含 $n$ 个正整数的数组 $a_1, a_2, \dots, a_n$。你需要找到满足以下条件的数对 $(L, R)$(其中 $L \le R$)的数量:$a_L \bmod a_{L+1} \bmod \dots \bmod a_R = a_R \bmod a_{R-1} \bmod \dots \bmod a_L$,其中 $\bmod$ 定义为取模运算。

输入格式

第一行包含一个整数 $n$ —— 数组的大小。 第二行包含 $n$ 个整数 $a_1, a_2, \dots, a_n$ —— 数组的元素。

数据范围

$1 \le n \le 10^5$ $1 \le a_i \le 3 \cdot 10^5$

输出格式

输出一个整数 —— 满足给定条件的数对 $(L, R)$ 的数量。

样例

输入 1

2
5 5

输出 1

3

输入 2

3
8 3 5

输出 2

4

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.