2132. Pythagorean triplets

单点时限: 2.0 sec

内存限制: 256 MB

In this problem you are required to do the following: Given a number n, you have to calculate the number of pythagorean triplets (a,b,c) such that a < b < c <= n and a,b,c are relatively prime to each other, that is they have no common factor apart from 1. You also have to compute the number of integers 0 < p <= n which are not a part of any triplet.

输入格式

The input is a sequence of positive integers, each of which appears on a single line. The input is terminated by 0. You need not process this case. Each input integer will be atmost 100000.

输出格式

For each input number n, print two integers separated by a blank space. The first number is the number of pythagorean triplets, each of whose component is less than of equal to n, and whose components do not have any common factor between them. The second is the number of integers greater than 0 and less than or equal to n which are not a part of any triplet (not just relatively prime triplets).

样例

Input
10
25
100
0
Output
1 4
4 9
16 27

3 人解决,17 人已尝试。

3 份提交通过,共有 40 份提交。

9.4 EMB 奖励。

创建: 15 年,11 月前.

修改: 6 年,8 月前.

最后提交: 9 月,2 周前.

来源: Codewars 2006

题目标签