bzoj#P1522. [POI2006]Kry
[POI2006]Kry
Statement
Byteman is a scientist who investigates creation of crystals consisting of atoms of different elements.
He has designed a special process for creating crystals and has discovered a formula specifying theamount of elements that can be used to create a crystal. Now, he wonders how many differentcrystals can be created in such process.
For non-negative integers and , by we shall denote their bit-wise xor. The basic xor forsingle bits is defined by:
,.
Byteman knows different elements that can be used to create crystals -these are numbered from to . For each element there is an upper bound on number of atoms of this elementthat can be used to create a crystal. Byteman can create one unique crystal composed of atomsof the element (for ), if and only if:
- for
- , and
- .
Note that the last condition is quite obvious and essentially states that every crystal is composed ofat least one atom.
TaskWrite a programme which:
reads form the standard input: the number of elements and the bounds on numbers of atoms of particular elements, computes the number of different crystals that can be created, writes the result to the standard output.
Input Format
The first line of the standard input contains the number of elements , .
The second, last line of the standard input contains positive integers , separated by single spaces,.
Output Format
Your programme should write one integer to the standard output - total number of different crystals that can be created. You can assume that this number is less than .
3
2 1 3
5