#P2111. Probability Threshold in a True/False Test

    ID: 15393 Type: Default 1000ms 256MiB

Probability Threshold in a True/False Test

Probability Threshold in a True/False Test

After the English exam ended and the bell rang, Xiaohong approached Xiaoming asking to compare answers using his exam paper. Xiaoming, known as the English expert, lent it to her without hesitation. When Xiaohong checked, she found many discrepancies and got worried. Xiaoming consoled her: "It's okay, I'm not the perfect answer key; I might not be 100% correct."

We know that Xiaoming’s answers are correct with probability $\frac{A}{100}$ and that there are $N$ true/false questions in total. You are given a binary string $S$ of length $N$, where each character is either 1 (indicating that Xiaohong’s answer matched Xiaoming’s answer) or 0 (they differ). Thus, for every question:

  • If the character is 1, then Xiaohong’s answer is correct with probability $\frac{A}{100}$.
  • If the character is 0, then her answer is correct with probability $1-\frac{A}{100}$.

Your task is to compute the probability that Xiaohong got at least $Q$ questions correct. The final answer should be printed with 6 decimal places.

Note: All questions are independent and are of the true/false type.

inputFormat

The input consists of two lines:

  1. The first line contains two integers $A$ and $Q$, where $A$ is the accuracy percentage of Xiaoming's answers, and $Q$ is the target number of correct answers.
  2. The second line contains a binary string $S$ of length $N$, representing the result of comparing Xiaohong's answers with Xiaoming's. '1' indicates the answers are the same, and '0' indicates they are different. Note that $N$ is implicitly defined by the length of $S$.

outputFormat

Print the probability that Xiaohong got at least $Q$ questions correct. The answer should be a floating-point number rounded to 6 decimal places.

sample

80 2
11
0.640000

</p>