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

15128번 - Congruent Numbers 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
2 초 512 MB42321745162041.242%

문제

A congruent number is an integer that is the area of some right triangle where the length of each side of the triangle is a rational number. For this problem, we’ll only consider the legs of the right triangle, and not the hypotenuse.

A rational number is a fraction, p/q, where p, the numerator, and q, the denominator, are integers. Note that if q = 1, then p/1 is an integer, so any integer is a rational number.

Given two rational numbers which are the non-hypotenuse legs of a right triangle, determine if the area of that triangle is a congruent number. For the purposes of this problem, it is not necessary for the length of the hypotenuse to be a rational number.

입력

Each input will consist of a single test case. Note that your program may be run multiple times on different inputs. Each test case will consist of a single line with four integers p1, q1, p2 and q2 (1 ≤ p1,q1,p2,q2 ≤ 100,000) where p1/q1 and p2/q2 are the rational numbers which are the sides of a right triangle.

출력

Output a single integer, which is 1 if the area of the triangle is an integer, 0 if not. Note that the area has to be an integer, not just a rational number.

제한

예제 입력 1

3 1 4 1

예제 출력 1

1

예제 입력 2

15 1 28 3

예제 출력 2

1

예제 입력 3

1 2 3 4

예제 출력 3

0

예제 입력 4

1 1 10 1

예제 출력 4

1

힌트

출처

ICPC > Regionals > North America > Southeast USA Regional > 2017 Southeast USA Regional Programming Contest > Division 2 A번

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

출처

대학교 대회

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

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