The Prior Probability
Halyard Mail is building a filter that sorts incoming messages into labels. Before a single word of a new message has been looked at, the filter needs a starting belief about each label: how common that label was in the archive it learned from. That starting belief has a name -- the prior. The archive has already been boiled down to one count per label, and the team wants the prior for one label in particular.
Task: Print the prior for the named label.
Input
The first line holds one integer n, the number of labels. Each of the next n lines holds a label and its count in the archive, separated by a single space; a label contains no spaces. The last line holds the label whose prior is wanted, which is always one of the n.
Output
One line holding that label's share of the whole archive, rounded to 4 decimal places. Every label's count is part of the archive, the named one included.
Example:
Input:
2
spam 40
ham 60
spam
Output:
0.4000
Sign in to solve this problem
Reading problems is free for everyone — solving them (Run, Submit, and tracking what you've solved) needs an account.
Sign in