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: Eventually periodic sequence
Description Given is a function f is defined recursively as follows: ^{ k}(n)f and ^{ 1}(n) = f(n)f = ^{ k+1}(n)f(f. ^{ k}(n))It is easy to see that each such sequence Input Each line of input contains 2 x * 7 + N %is the RPN rendition of the more familiar infix (2*x+7)%N. All input lines are shorter than 100 characters. The last line of input has N equal 0 and should not be processed. Output For each line of input, output one line with one integer number, the period of Sample Input 10 1 x N % 11 1 x x 1 + * N % 1728 1 x x 1 + * x 2 + * N % 1728 1 x x 1 + x 2 + * * N % 100003 1 x x 123 + * x 12345 + * N % 0 0 0 N % Sample Output 1 3 6 6 369 Source Waterloo Local Contest, 2006.5.27 |

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

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

Any problem, Please Contact Administrator