CF304A.Pythagorean Theorem II

普及-

通过率:0%

时间限制:3.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

In mathematics, the Pythagorean theorem — is a relation in Euclidean geometry among the three sides of a right-angled triangle. In terms of areas, it states:

In any right-angled triangle, the area of the square whose side is the hypotenuse (the side opposite the right angle) is equal to the sum of the areas of the squares whose sides are the two legs (the two sides that meet at a right angle).

The theorem can be written as an equation relating the lengths of the sides a, b and c, often called the Pythagorean equation:

_a_2 + _b_2 = _c_2

where c represents the length of the hypotenuse, and a and b represent the lengths of the other two sides.

Given n, your task is to count how many right-angled triangles with side-lengths a, b and c that satisfied an inequality 1 ≤ a ≤ b ≤ c ≤ n.

在数学中,勾股定理(Pythagorean theorem)是欧几里得几何中直角三角形三边之间的一种关系。用面积的语言表述为:

在任意一个直角三角形中,以斜边(即直角的对边)为边长的正方形的面积,等于以另外两条直角边(即在直角处相交的两条边)为边长的两个正方形的面积之和。

该定理可写成一个关于三边长度 aa、bb 和 cc 的方程,通常称为勾股方程:

a2+b2=c2a^2 + b^2 = c^2

其中 cc 表示斜边的长度,而 aa 和 bb 表示其余两条边的长度。

给定正整数 nn,你的任务是统计满足不等式 1≤a≤b≤c≤n1 \leq a \leq b \leq c \leq n 的直角三角形(边长为 aa、bb、cc)的个数。

输入格式

The only line contains one integer n (1 ≤ n ≤ 104) as we mentioned above.

唯一的一行包含一个整数 nn(1 ≤ n ≤ 1041 \leq n \leq 10^4),如上所述。

输出格式

Print a single integer — the answer to the problem.

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

输入输出样例

  • 输入#1

    5

    输出#1

    1
  • 输入#2

    74

    输出#2

    35

输入解题思路,AI测评打分。不知道怎么写?

首页