codeforces-scrape

Codeforces scraped problems and editorials
git clone git://git.laack.co/codeforces-scrape.git
Log | Files | Refs | README

244B.md (1341B)


      1 Source: https://codeforces.com/problemset/problem/244/B
      2 
      3 B. Undoubtedly Lucky Numbers
      4 
      5 time limit per test
      6 
      7 2 seconds
      8 
      9 memory limit per test
     10 
     11 256 megabytes
     12 
     13 input
     14 
     15 stdin
     16 
     17 output
     18 
     19 stdout
     20 
     21 Polycarpus loves lucky numbers. Everybody knows that lucky numbers are positive integers, whose decimal representation (without leading zeroes) contain only the lucky digits *x* and *y*. For example, if *x* = 4, and *y* = 7, then numbers 47, 744, 4 are lucky.
     22 
     23 Let's call a positive integer *a* undoubtedly lucky, if there are such digits *x* and *y* (0 ≤ *x*, *y* ≤ 9), that the decimal representation of number *a* (without leading zeroes) contains only digits *x* and *y*.
     24 
     25 Polycarpus has integer *n*. He wants to know how many positive integers that do not exceed *n*, are undoubtedly lucky. Help him, count this number.
     26 
     27 Input
     28 
     29 The first line contains a single integer *n* (1 ≤ *n* ≤ 109) — Polycarpus's number.
     30 
     31 Output
     32 
     33 Print a single integer that says, how many positive integers that do not exceed *n* are undoubtedly lucky.
     34 
     35 Examples
     36 
     37 Input
     38 
     39 ```
     40 10
     41 ```
     42 
     43 Output
     44 
     45 ```
     46 10
     47 ```
     48 
     49 Input
     50 
     51 ```
     52 123
     53 ```
     54 
     55 Output
     56 
     57 ```
     58 113
     59 ```
     60 
     61 Note
     62 
     63 In the first test sample all numbers that do not exceed 10 are undoubtedly lucky.
     64 
     65 In the second sample numbers 102, 103, 104, 105, 106, 107, 108, 109, 120, 123 are not undoubtedly lucky.