Logo
(追記) (追記ここまで)

27858번 - Counting Pythagorean Triples 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
2 초 1024 MB69484266.667%

문제

A Pythagorean triple is a set of three positive integers, a, b and c, for which:

a² + b² = c²

A Pythagorean triple is a Primitive Pythagorean Triple (PPT) if a, b and c have no common factors.

Write a program which takes as input a positive integer, n, and outputs a count of:

  1. The number of different PPTs in which n is the hypotenuse ( c ).
  2. The number of non-primitive Pythagorean triples in which n is the hypotenuse ( c ).
  3. The number of different PPTs in which n is one of the sides ( a or b ).
  4. The number of non-primitive Pythagorean triples in which n is the one of the sides ( a or b ).

For the same a, b, c: b, a, c is the “same” as a, b, c (i.e it only counts once). Non-primitive Pythagorean triples are Pythagorean triples which are not PPT.

For example, in the case of n = 65, the following are the cases for each of the criteria above:

  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

입력

Input consists of a single line containing a single non-negative decimal integer n, (3 ≤ n ≤ 2500).

출력

There is one line of output. The single output line contains four decimal integers:

The first is the number of different PPTs in which n is the hypotenuse ( c ).

The second is the number of non-primitive Pythagorean triples in which n is the hypotenuse ( c).

The third is the number of different PPTs in which n is the one of the sides ( a or b ).

The fourth is the number of non-primitive Pythagorean triples in which n is the one of the sides (a or b).

제한

예제 입력 1

65

예제 출력 1

2 2 2 2

예제 입력 2

64

예제 출력 2

0 0 1 4

예제 입력 3

2023

예제 출력 3

0 2 2 5

힌트

출처

ICPC > Regionals > North America > Greater New York Region > 2022 Greater New York Programming Contest D번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /