QOJ.ac

QOJ

時間限制: 1.0 s 記憶體限制: 512 MB 總分: 100 可 Hack ✓

#7146. 等比数列

统计

bobo 热爱等比数列!所以他想知道序列 $a_1, a_2, \dots, a_n$ 中长度为 3 的等比数列的个数。 也就是说,计算满足 $i < j < k$ 且 $a_i \cdot a_k = a_j^2$ 的三元组 $(i, j, k)$ 的数量。

输入格式

第一行包含一个整数 $n$ ($1 \le n \le 1000000$)。 第二行包含 $n$ 个整数 $a_1, a_2, \dots, a_n$ ($1 \le a_1 < a_2 < \dots < a_n \le 1000000$)。

输出格式

输出一个整数,表示等比数列的个数。

样例

输入 1

3
1 2 4

输出 1

1

输入 2

4
1 2 4 8

输出 2

2

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.