[Solution] K Flip CodeChef Solution | Solution CodeChef
Problem
Chef is given a binary string of length .
In one operation, Chef has to choose exactly indices and flip their values.
Chef can perform the above operation any number of times. Find the number of distinct binary strings Chef can obtain.
Since the answer might be large, output it module .
Input Format
- The first line of input will contain a single integer , denoting the number of test cases.
- Each test case consists of multiple lines of input.
- The first line of each test case contains two space-separated integers and , as mentioned in statement.
- The next line contains the binary string .
Output Format
For each test case, output the number of distinct binary strings Chef can obtain, modulo .
Explanation:
Test case : We can flip index in an operation. Thus, we can generate all possible binary strings of length . The total number of distinct strings that can be generated are .
Test case : We have to flip indices at once. Thus, we can convert to . The only possible strings that can be generated are and . Thus, the answer is .
No comments:
Post a Comment