http://codeforces.com/problemset/problem/535/BThe problem is:You are given a lucky number n. Lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.If we sort all lucky numbers in increasing order, what's the 1-based index of n?Input: a lucky number n (1n109).Output: index of n among all lucky numbers.Examples: input: 4, output: 1 input: 7, output: 2 input: 77, output: 6The Editorial solutions says,1 :  Consider n has x digits, f(i)= decimal representation of binary string i, m is a binary string of size x and its i-th digit is 0 if and only if the i-th digit of n is 4. Finally, answer equals to 21+22++2x-1+f(m)+1.2 : Count the number of lucky numbers less than or equal to n using bitmask (assign a binary string to each lucky number by replacing 4s with 0 and 7s with 1).My question is ,how the Binary representations are used to calculate the position of the string?I am just not understanding this.
How to use Bitmasking to solve this problem?
algorithms;counting