P2111 An Unexpected Encounter in the Exam Hall
Background
In a certain elite school in this city, there is a top student named Xiao Ming (to protect the protagonist’s privacy, the name “Xiao Ming” is used). During the midterm exam, Xiao Ming had a stroke of luck and met a girl in the exam hall. Her name is Xiao Hong (also for privacy).
Description
After the English exam ended and the bell rang, she took the initiative to talk to Xiao Ming and immediately asked to borrow his English paper to check answers. Xiao Ming is recognized as an English master, so he lent it to her without hesitation. After checking, Xiao Hong found her answers were vastly different; she broke into a cold sweat. At this moment, Xiao Ming came over to comfort her: “It’s okay, I’m not the official answer key; I might not be entirely correct.”
It is known that Xiao Ming’s accuracy rate is $A\%$, and there are $N$ questions in total. You are given Xiao Hong’s comparison result $S$ (a 01 string of length $N$, where `1` means their answers are the same and `0` means they are different). To simplify the problem, all questions are True/False questions.
Please help Xiao Hong write a program to compute the probability that she answers at least $Q$ questions correctly.
(P.S. Xiao Ming later gave that paper to Xiao Hong. Don’t overthink it—it wasn’t a love token.)
Input Format
The first line contains three positive integers $N$, $A$, $Q$.
The second line contains a 01 string $S$.
Output Format
One line containing a real number: the probability that she answers at least $Q$ questions correctly. Print $3$ decimal places.
Explanation/Hint
For $90\%$ of the testdata, $N \leq 50$, $N - 5 \leq Q \leq N$.
For the remaining $10\%$ of the testdata, $N \leq 10000$, $Q = 0$.
Translated by ChatGPT 5