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

31292번 - Compare Continued Fractions 다국어

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

문제

In this problem, you have to compare two rational numbers represented by their continued fractions.

A finite continued fraction is a sequence $[a_{0}; a_{1}, a_{2}, \ldots, a_{n}]$. The following restrictions are applied:

  • $n$ is a non-negative finite integer,
  • the elements $a_{0},ドル $a_{1},ドル $a_{2},ドル $\ldots,ドル $a_{n}$ are integers,
  • $a_{i} > 0$ for each $i > 0,ドル
  • $a_{n} > 1$ if $n > 0$.

These restrictions allow to establish a one-to-one correspondence between rational numbers and finite continued fractions: every rational number $x$ corresponds to the unique continued fraction $[a_{0}; a_{1}, a_{2}, \ldots, a_{n}]$ such that $$x = a_{0} + \frac {1} {a_{1} + \frac {1} {a_{2} + \frac {1} {\ddots + \frac {1} {a_{n}}}}}\text{.}$$ Thus, the following notation is used: $x = [a_{0}; a_{1}, a_{2}, \ldots, a_{n}]$. For example, $$\frac {17} {25} = 0 + \frac {1} {\frac {25} {17}} = 0 + \frac {1} {1 + \frac {8} {17}} = 0 + \frac {1} {1 + \frac {1} {\frac {17} {8}}} = \mathbf{0} + \frac {1} {\mathbf{1} + \frac {1} {\mathbf{2} + \frac {1} {\mathbf{8}}}}\text{,}$$ so we write $\frac {17} {25} = [0; 1, 2, 8]$.

Given the continued fractions for two rational numbers $x$ and $y,ドル find whether $x < y,ドル $x = y,ドル or $x > y$.

입력

The input consists of two lines. The first line contains the continued fraction for the rational number $x$. The second line contains the continued fraction for the rational number $y$.

Each continued fraction is given as a sequence of integers separated by single spaces. First goes an integer $n,ドル the length of the continued fraction (0ドル \le n \le 100,000円$). It is followed by $(n + 1)$ integers which are the elements of the continued fraction: $a_{0},ドル $a_{1},ドル $a_{2},ドル $\ldots,ドル $a_{n}$ ($|a_{i}| \le 10^{9}$). It is guaranteed that $a_{i} > 0$ for each $i > 0$ and $a_{n} > 1$ if $n > 0$.

출력

On the first line of output, print a single character: "<" if $x < y,ドル "=" if $x = y,ドル or ">" if $x > y$.

제한

예제 입력 1

1 0 3
2 0 1 2

예제 출력 1

<

$x = 0 + \frac{1}{3} = \frac{1}{3},ドル $y = 0 + \frac{1}{1 + \frac{1}{2}} = \frac{2}{3}$

예제 입력 2

0 1
0 1

예제 출력 2

=

$x = 1,ドル $y = 1$

예제 입력 3

1 -1 2
0 -1

예제 출력 3

>

$x = -1 + \frac{1}{2} = -\frac{1}{2},ドル $y = -1$

힌트

출처

Contest > Open Cup > 2014/2015 Season > Stage 1: Grand Prix of SPb B번

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

출처

대학교 대회

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

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