4
1 11350:Stren-Brocot Tree ★★☆☆ 題題Contest Archive with Online Judge 題題11350: Stren-Brocot Tree 題題題李李李 題題題題2008 李 12 李 7 李 題題Stern-Brocot tree 李李李李李李李李李 李李李李李李李 李李李李 0 李李李李李李李李李李李李李李李李李 李李李 李李李李李李 李 李李 李李李李 李李李李 ()。一( 90 李李 L 李 R L 李李R 李李 李李李李李李李李李李 ?

11350:Stren-Brocot Tree

Embed Size (px)

DESCRIPTION

11350:Stren-Brocot Tree. ★★☆☆ 題組: Contest Archive with Online Judge 題號: 11350: Stren-Brocot Tree 解題者: 李育賢 解題日期: 2008 年 12 月 7 日 題意: Stern-Brocot tree 可以表示所有的分數。設最右界為無限大,最左界為0 。目前的值就是之前左右邊界分子分母個別相加(參考下頁圖)。給一個字串(長度最大 90 )只包含 L 和 R , L 往左, R 往右,問最後得到的分數為何 ?. 題意範例: Sample Input: 3 RL - PowerPoint PPT Presentation

Citation preview

Page 1: 11350:Stren-Brocot Tree

1

11350:Stren-Brocot Tree ★★☆☆ 題組: Contest Archive with Online Judge 題號: 11350: Stren-Brocot Tree 解題者:李育賢 解題日期: 2008 年 12 月 7 日 題意:

Stern-Brocot tree 可以表示所有的分數。設最右界為無限大,最左界為 0 。目前的值就是之前左右邊界分子分母個別相加(參考下頁圖)。給一個字串(長度最大 90 )只包含 L 和 R , L 往左, R 往右,問最後得到的分數為何 ?

Page 2: 11350:Stren-Brocot Tree

2

Page 3: 11350:Stren-Brocot Tree

3

題意範例: Sample Input:

3 RL RLR RRL

Sample Output:3/2 5/3 5/2

Page 4: 11350:Stren-Brocot Tree

4

解法:直接作即可,但注意需用 long long 。