At Most One Defective Item
Kestrel Optics ships camera lenses in trays. Each lens has some chance of coming off the line with a coating flaw, and because the trays are filled from several machines at once, one bad lens tells you nothing about the next one in the tray.
The quality team has drafted a rule: a tray passes inspection if the inspector finds no more than one flawed lens in it, otherwise the whole tray goes back. Before the plant manager signs that rule off, he wants to know what proportion of trays it would actually let through - a rule that rejects half the output is not a rule anyone can run a factory on. He asks for the figure on every product line, and the lines differ both in tray size and in how often they spoil a lens.
Task: Print the probability that a tray contains at most 1 flawed lens - that is, either none at all or exactly one - rounded to 4 decimals.
Input
Two lines: how many lenses a tray holds, a whole number of at least 1, and the chance a single lens comes off flawed, a decimal between 0 and 1.
Output
One line holding the probability, rounded to 4 decimals and printed the way Python prints a float - 0.7358.
Example:
Input:
20
0.05
Output:
0.7358
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