Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|

Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |

Language: Period of an Infinite Binary Expansion
Description Let { { a_{r+1}a_{r+2}...a_{r+s})^{w}for some integers The subsequence preperiod of {x} and x_{2} = a_{r+1}a_{r+2} ... a_{r+s} is the period of {x}.Suppose that | For example, However, we can write 1/10 also as 1/10 = 0.0(0011) The least period of 1/10 starts at the 2nd bit to the right of the binary point and the the length of the least period is 4. Write a program that finds the position of the first bit of the least period and the length of the least period where the preperiod is also the minimum of a positive rational number less than 1. Input Each line is test case. It represents a rational number Output Each line corresponds to a single test case. It represents a pair where the first number is the position of the first bit of the least period and the the second number is the length of the least period of the rational number. Sample Input 1/10 1/5 101/120 121/1472 Sample Output Case #1: 2,4 Case #2: 1,4 Case #3: 4,4 Case #4: 7,11 Source |

[Submit] [Go Back] [Status] [Discuss]

All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di

Any problem, Please Contact Administrator