#B4137. Lucky Number Count
Lucky Number Count
Lucky Number Count
Given a positive integer \( n \), count how many lucky numbers there are in the range \( [1, n] \). A positive integer \( x \) is considered lucky if at least one of the following conditions holds:
- \( x \) is a multiple of \( 4 \);
- \( x \) is a multiple of \( 7 \);
- The string representation of \( x \) contains the substring
44
or77
.
For example, \(105\) (a multiple of \(7\)), \(442\) (contains 44
), and \(1284\) (a multiple of \(4\)) are lucky numbers, while \(474\) is not.
inputFormat
The input consists of a single integer \( n \) (\(1 \le n \le 10^9\)).
outputFormat
Output a single integer representing the count of lucky numbers between \(1\) and \( n \).
sample
50
18