Hudson River TradingOA #3
Count Fancy Numbers
Estimated MediumJudge-ready
Topics (AI-labelled)Bits & Math
A positive integer is called fancy if its base-4 representation contains only the digits 0 and 1. Given n, count the positive fancy integers strictly less than n; 0 is not counted.
Input
The input is one integer n (1≤n≤10^9).
Output
Output the number of positive integers that satisfy the condition.
Example 1
Input:
1
Output:
0
Example 2
Input:
10
Output:
3
Example 3
Input:
17
Output:
4
Editorial
Loading solution…