Partitioning

2.7

14 votes
Basic Programming, Basics of Implementation, Easy, Implementation
Problem

Given a binary string of length N(containing only 0's and 1's) and two integers C,P. 

Put exactly 3 dividers in the string so that the integer between first and second divider (its decimal equivalent) is C and that between second and third divider is P(its decimal equivalent). There cannot be more than 25 digits in binary representation of P or C(inclusive of preceeding or leading 0's). Find the number of ways to put these dividers.  

CONSTRAINTS:

1N106

1C,P<225

INPUT:

The first line contains a string of binary numbers. 

The next line contains 2 space-seperated integers C and P

OUTPUT:

In a single line, print the number of ways in which the 3 dividers can be put. 

Time Limit: 1
Memory Limit: 256
Source Limit:
Explanation

0|100|0011|, |0100|0011|

The number between 1st and 2nd divider is '0100' or '100' which is equivalent to 4 in decimal (equal to C)

The number between 2nd and 3rd divider is '0011'  which is equivalent to 3 in decimal (equal to P)

 

Editor Image

?