QOJ.ac

QOJ

Time Limit: 2 s Memory Limit: 512 MB Total points: 100

#1842. 数学

Statistics

给定一个包含 $n$ 个不同正整数的数组 $a$。请找出满足 $1 \le i, j \le n$ 且 $a_i^2 + a_j$ 为完全平方数的数对 $(i, j)$ 的数量。

输入格式

第一行包含一个整数 $n$ ($1 \le n \le 10^6$),表示数组的大小。 第二行包含 $n$ 个不同的正整数 $a_1, \dots, a_n$ ($1 \le a_i \le 10^6$)。

输出格式

输出一个整数:问题的答案。

样例

样例输入 1

5
1 2 3 4 5

样例输出 1

2

说明

在样例中,有两个这样的数对,分别为 $1^2 + 3 = 4 = 2^2$ 和 $2^2 + 5 = 9 = 3^2$。

Editorials

IDTypeStatusTitlePosted ByLast UpdatedActions
EditorialOpen Official EditorialQingyu- Download

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.