/ OPS / 题库 /

Stern-Brocot Tree

Stern-Brocot Tree

#描述#
Now I will introduce a pretty tree which is called Stern-Brocot Tree, because it was discovered independently by Moritz Stern, a German mathematician, and Achille Brocot, a French clockmaker. The idea is to start with the two fractions (0/1,1/0) and then to repeat the following operation as many times as desired:<br />
Insert (m+m')/(n+n') between two adjacent fractions m/n and m'/n'.<br />
The new fraction (m+m')/(n+n') is called the mediant of m/n and m'/n'.<br />
For example, the first step gives us one way entry between 0/1 and 1/0,<br />
<center>0/1, 1/1 , 1/0<br /></center>
And the next gives two more,<br />
<center>0/1, 1/2, 1/1, 2/1, 1/0<br /></center>
Then will be 4,8,16 more, like the follow picture:<br />
<img src="http://bbs.zjut.com/attachments/forumid_369/11050821527b5b704e94d8e245.png" /><br />
Well, my question is giving you an arbitrary fraction, could you find this fraction in Stern-Brocot Tree ?

#格式#
##输入格式##
The first line is the number of the fractions n
The next n line is the fractions, the numerator will be between 1 to 10^100,inclusive; the denominator will be between 1 to 10^100 inclusive.

##输出格式##
If the fraction could be found in Stern-Brocot Tree , then you should output “Yes”, else you should output “No”.

#样例1#
##样例输入1##

3
1/1
2/1
2/2

##样例输出1##

Yes
Yes
No

#限制#
1000ms
32768KB

#提示#
I consider that two fractions are same while their numerators is same and their denominator are also same, eg: 2/2 is not equal to 1/1.

#来源#
guoxu

信息

ID
1835
难度
5
分类
category1 点击显示
标签
递交数
0
已通过
0
通过率
?
上传者