QOJ.ac

QOJ

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

#5676. 计算勾股数

الإحصائيات

勾股数(Pythagorean triple)是指三个正整数 $a, b$ 和 $c$,满足: $$a^2 + b^2 = c^2$$

如果 $a, b$ 和 $c$ 没有公因数,则称该勾股数为本原勾股数(Primitive Pythagorean Triple, PPT)。

编写一个程序,输入一个正整数 $n$,输出以下计数: 1. 以 $n$ 为斜边($c$)的不同 PPT 的数量。 2. 以 $n$ 为斜边($c$)的非本原勾股数的数量。 3. 以 $n$ 为直角边之一($a$ 或 $b$)的不同 PPT 的数量。 4. 以 $n$ 为直角边之一($a$ 或 $b$)的非本原勾股数的数量。

对于相同的 $a, b, c$:$b, a, c$ 与 $a, b, c$ 被视为“相同”(即只计数一次)。非本原勾股数是指不是 PPT 的勾股数。

例如,当 $n = 65$ 时,上述各项的示例如下: 1. 33, 56, 65; 63, 16, 65 2. 39, 52, 65; 25, 60, 65 3. 65, 72, 97; 65, 2112, 2113 4. 65, 420, 425; 65, 156, 169

输入格式

输入包含一行,为一个非负十进制整数 $n$($3 \le n \le 2500$)。

输出格式

输出一行。该行包含四个十进制整数: 第一个是以 $n$ 为斜边($c$)的不同 PPT 的数量。 第二个是以 $n$ 为斜边($c$)的非本原勾股数的数量。 第三个是以 $n$ 为直角边之一($a$ 或 $b$)的不同 PPT 的数量。 第四个是以 $n$ 为直角边之一($a$ 或 $b$)的非本原勾股数的数量。

样例

样例输入 1

65

样例输出 1

2 2 2 2

样例输入 2

64

样例输出 2

0 0 1 4

样例输入 3

2023

样例输出 3

0 2 2 5

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.