您的位置:首页 > 大数据 > 人工智能

USACOTrainning.Ordered Fractions

2010-04-21 08:41 225 查看
这题简单,但看到analysis里面的这个解法真是囧。

We notice that we can start with 0/1 and 1/1 as our ``endpoints'' and recursively generate the middle points by adding numerators and denominators.

0/1                                                              1/1
1/2
1/3                      2/3
1/4              2/5         3/5                 3/4
1/5      2/7     3/8    3/7   4/7   5/8       5/7         4/5

Each fraction is created from the one up to its right and the one up to its left. This idea lends itself easily to a recursion that we cut off when we go too deep.
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: