Happy numbers again
Limits: 4 sec., 256 MiB
This statement was translated automatically from Ukrainian.
Everyone knows that a happy number is one whose decimal representation contains only fours and sevens. For example, the numbers 4, 7, 47, 7777, and 4744474 are happy.
Zenyk considers a pair of happy numbers \(x
< y\) to be interesting if \(x\) \(AND\) \(y =
0\), where \(AND\) is the
bitwise "AND" operation.
Can you count how many interesting pairs of numbers there are in the range \([L, R]\)?
Input
The single line contains two integers separated by a space — \(L\) and \(R\).
Output
Print a single integer — the number of interesting pairs \(x\) and \(y\) such that \(L \le x < y \le R\).
Constraints
\(1 \le L \le R \le 10^{18}\).
Samples
| Input (stdin) | Output (stdout) |
|---|---|
| 4 77 | 1 |
| Input (stdin) | Output (stdout) |
|---|---|
| 1 1000 | 6 |
Notes
In the first test, the only pair of numbers that satisfy the problem condition is \(4\) and \(74\).
Submit a solution
| Element Type | Created | Who | Problem | Compiler | Result | Time (sec.) | Memory (MiB) | # | Actions |
|---|
| Element Type | Created | Who | Problem | Compiler | Result | Time (sec.) | Memory (MiB) | # | Actions |
|---|