问题链接:http://icpc.upc.edu.cn/problem.php?cid=1809&pid=5
题目描述
**An infinite full binary tree labeled by positive rational numbers is defi ned by:• The label of the root is 1/1.• The left child of label p/q is p/(p+q).• The right child ofl abel p/q is (p+q)/q.The top of the tree is shown in the following figure:
**A rational sequence is defined by doing a level order (breadth first) traversal of the tree (indicated by the light dashed line). So that:F(1) = 1/1, F(2) = 1/2, F(3) = 2/1, F(4) = 1/3, F(5) = 3/2, F(6) = 2/3, . . .Write a program which takes as input a rational number, p