Fancy That!
Practice
3.3 (3 votes)
Algorithms
Dynamic programming
Medium
Problem
38% Success 1107 Attempts 30 Points 1s Time Limit 256MB Memory 1024 KB Max Code
Misha has decided to come up with the following puzzle to ask her friends:
Find the count of fancy numbers in the range \([L, R]\). Fancy numbers have an interesting property. The property states that the sum of numbers got as the result of adding all the subsequences that can be formed from the given number will be even.
For example, the number \(202\) is a fancy number as the sum of numbers that are formed by all of its subsequences is calculated as: \(2 + 0 + 2 + 20 + 02 + 22 + 202 = 250\). Since \(250\) is an even number, the number \(202\) is considered to be fancy.
Input format
- First line: An integer \(T\) denoting the number of test cases
- Each of the next \(T\) lines: Two space-separated integers \(L\) and \(R\)
Output format
- Print the answer for each test case in a separate line.
Constraints
\(1 \le T \le 100\)
\(1 \le L,\ R \le 10^{10}\)
Submissions
Please login to view your submissions
Similar Problems
Points:30
68 votes
Tags:
Bit ManipulationBit manipulationDynamic ProgrammingMediumOpen
Points:30
14 votes
Tags:
AlgorithmsApprovedBit ManipulationDynamic ProgrammingMedium
Points:30
26 votes
Tags:
AlgorithmsDynamic ProgrammingMedium
Editorial