[BOJ 15224] EvenOdd
View as PDF
Submit solution
Assembly, Awk, C, C++, Java, Pascal, Perl, Python, Sed, Text
Points:
4
Time limit:
2.0s
Memory limit:
512M
Problem types
Allowed languages
Consider the following function f(X), which takes a single positive integer as argument, and returns an integer.</p>
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 X, this function terminates. Given an interval [L, R], compute the sum
S = f(L) + f(L + 1) + · · · + f(R − 1) + f(R).
입력 형식
The first and only line of input contains two integers L and R (1 ≤ L ≤ R ≤ 1018).
출력 형식
Output the result S modulo the prime 109 + 7.
예제 입력 1
1 127
예제 출력 1
1083
예제 입력 2
74 74
예제 출력 2
11
Comments