Cool numbers
Practice
2.5 (2 votes)
Implementation
Recruit
Approved
Easy Medium
Ready
Mathematics
Approved
Problem
49% Success 3117 Attempts 30 Points 1s Time Limit 256MB Memory 1024 KB Max Code
Today Oz is busy with cool numbers. Cool numbers are positive integers whose decimal representation contains only the cool digits 2 and 5. For example, numbers 25, 522, 2 are cool and 7, 15, 265 are not.
Let f(k) be the smallest cool number greater than or equals k. Oz is interested what is the value of the following expression for a given pair (l,r) :
Input :
The first line of input contains an integer T - number of test cases. Each test case consist of two integers l and r.
Output :
For each test case output required answer.
Constraint :
1 ≤ T ≤ 50
1 ≤ l ≤ r ≤ 109
Submissions
Please login to view your submissions
Similar Problems
Points:50
5 votes
Tags:
AlgorithmsApprovedGraphsHardOpen
Points:30
4 votes
Tags:
Medium
Points:30
Tags:
MathematicsMediumOpenApprovedProbability and Statistics
Editorial