Preparation for the Contest
Limits: 2 sec., 256 MiB
In order to become “Miss High School” a girl has to be very beautiful and extreamly smart, i.e. she should know how to solve algorithmic problems. Marichka is preparing for the contest very hard and now she is trying to solve to following problem:
“You are given integer N. Count the number of ordered pairs of positive integers (X, Y) both not greater than N such that there is at least one digit which is present in decimal representations of both X and Y. For example, 47 and 1024 have common digit 4, while 658 and 270 have no commod digit. Note that if \(X \neq Y\) ordered pairs (X, Y) and (Y, X) are considered as different.”
Would you please help Marichka to solve this problem so she could have more time for other preparations?
Input
Integer N.
Output
The number of ordered pairs.
Constraints
\(1 \le \mathbf{N} \le 10^9\),
50% of tests: \(\mathbf{N} \le 10^6\).
Samples
Input (stdin) | Output (stdout) |
---|---|
12 | 26 |
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 |
---|