3428. EvenOdd

单点时限: 1.0 sec

内存限制: 512 MB

Consider the following function , which takes a single positive integer as argument, and returns an integer.

function f(X):
    iterations := 0
    while X is not 1:
        if X is even:
            divide X by 2
        else:
            add 1 to X
        add 1 to iterations
    return iterations

It can be shown that for any positive integer , this function terminates.

Given an interval , compute the sum

输入格式

The first and only line of input contains two integers and ().

输出格式

Output the result modulo the prime .

样例

Input
1 127
Output
1083
Input
74 74
Output
11

10 人解决,19 人已尝试。

12 份提交通过,共有 57 份提交。

6.8 EMB 奖励。

创建: 2 年,2 月前.

修改: 2 年,2 月前.

最后提交: 10 月,3 周前.

来源: KTH Challenge 2017

题目标签