All submissions for this problem are available.
Binary Representation is Ilya's favourite. She loves binary representation so much that she has completely stopped using decimal representation.
One day on their way to a hackathon her friend Vanya gave Ilya a simple problem to solve. Despite being crazy for binary numbers, Ilya is finding it difficult to answer Vanya problem. The problem is as follows:
Given an array of N positive integers 'A' and a range [a, b], how many numbers exists in range [a, b] (both inclusive), whose binary representation donot contain the binary representation of any of elements of A as a substring.
Can your help her?
First line consists of an integer N, the number of elements in A.
The second line consist of N integers which represents the array A.
The third line consist of two integers a and b.
No of positive integers that follows the constraint mentioned above.
- 1 <= N <= 104
- 1 <= Ai <= 108
- 1 <= a <= b <= 1015
2 4 6 8 10
The numbers' binary representation cannot contain '10' because 2 in present in A. The only numbers left are those whose representation consist of only 1's
3 with binary representation 11
7 with binary representation 111
15 with binary representation 1111
31 with binary representation 11111
63 with binary representation 111111
|Time Limit:||1 sec|
|Source Limit:||50000 Bytes|
|Languages:||C, CPP14, JAVA, PYTH, PYTH 3.6, PYPY, CS2, PAS fpc, PAS gpc, RUBY, PHP, GO, NODEJS, HASK, SCALA, D, PERL, FORT, WSPC, ADA, CAML, ICK, BF, ASM, CLPS, PRLG, ICON, SCM qobi, PIKE, ST, NICE, LUA, BASH, NEM, LISP sbcl, LISP clisp, SCM guile, JS, ERL, TCL, PERL6, TEXT, SCM chicken, CLOJ, FS|
Fetching successful submissions