Author: | A. Klenin | Time limit: | 2 sec | |
Input file: | input.txt | Memory limit: | 64 Mb | |
Output file: | output.txt |
Some applications (such as compression algorithms) require searching a memory area for arbitrary bit strings.
Your program must find the first occurrence of the given bit string in the sequence of numbers generated by an arithmetic progression: a,a+b,a+2b,…,a+N×b. Numbers are stored in a continuous memory area as 32-bit unsigned integers in the little-endian byte order. Bits in byte are counted from the least significant to the most significant one.
For example, number 123456 will be stored as a sequence of four bytes with hexadecimal values "40 E2 01 00", interpreted as bit string "00000010 01000111 10000000 00000000" (spaces inserted for readability only). So the occurrence of the bit substring "1001" would be at position 7.
Note that the occurrence can cross boundaries between numbers.
0≤a,b,N,a+N×b≤232−1
0≤N≤5×106
Bit string consists of 1 to 32 bits.
No. | Input file (input.txt ) |
Output file (output.txt ) |
---|---|---|
1 |
|
|
2 |
|
|
3 |
|
|