1755 - DS_2019_hw0 Scoreboard

Time

2019/09/24 13:30:00 2019/10/01 23:59:59

Clarification

# Problem Asker Description Reply Replier Reply Time For all team

# Problem Pass Rate (passed user / total user)
12370 DS_2019Fall_HW_test

12370 - DS_2019Fall_HW_test   

Description

        In this homework, you are asked to solve a very easy problem, the 3n+1 problem. Given an integer n, repeat the following procedure. If n is odd, set n to 3*n+1. Otherwise, set n to n/2. The procedure is terminated if n is equal to 1.

        For example, given the input 22, the following sequence of numbers will be encountered.

22 11 34 17 52 26 13 40 20 10 5 16 8 4 2 1 

It is possible to determine the number of numbers encountered before and including the 1 is reached. For a given n, this is called the cycle-length of n. In the example above, the cycle-length of 22 is 16.

        You are given a pair of integers x and y. Your task is to determine the maximum cycle length over all numbers and including x and y.

Input

The input will consist of a series of pairs of integer x and y, one pair of integer per line.

1 <= x < y <= 10000

Output

    For each pair of input x and y, output the maximum cycle-length for integers between and including x and y. Each output followed by a new line symbol.

Sample Input  Download

Sample Output  Download

Tags




Discuss