Hello, 2048!
Time limit1sMemory limit512 MB
Given l and r, find how many times the number formed by concatenating 2^l through 2^r in decimal divides evenly by 2, without building the huge number.
- Level
Hard8 of 10
- Topics
- Math, Number theory, Implementation
- Solved
- No attempts yet
Problem
Sungbin, who studies computer science, is especially fond of powers of two. One day, while looking at a calendar, he realized that the year 2048 was approaching. He wondered how likely it was for an arbitrary person to live through a year that is a power of two, and thought that this probability would decrease as time passed.
While staring at the number 2048, Sungbin noticed something interesting: it contains the digits 2, 4, and 8, which are themselves powers of two. This led him to the following question.
Let be the decimal number formed by writing in decimal notation and concatenating them in that order. How many times can be divided by 2 consecutively?
The number can become far too large to build directly. Write a program that answers Sungbin's question.
Input
The first line contains an integer , the number of test cases.
Each test case consists of two integers and separated by a space.
Output
For each test case, print one line containing the answer to Sungbin's question.