Smallest possible poll sample
Time limit1sMemory limit256 MB
Given a percentage printed to three decimals, find the smallest sample size n for which some count k rounds to that percentage.
- Level
Medium5 of 10
- Topics
- Math, Brute force
- Solved
- No attempts yet
Problem
A news story that quotes a poll usually prints a percentage instead of the raw vote counts. From that percentage alone, work out how small the sample could have been.
The question takes yes or no as its only answers. If of the people in the sample answered yes, then , and the story prints rounded at the fourth decimal place. When the fourth decimal digit is 5 or more the third decimal place goes up, otherwise everything from the fourth digit on is dropped.
Given the percentage printed in the story, find the smallest possible value of .
Input
The first line contains the number of test cases .
Each of the next lines contains one printed percentage, written with exactly three digits after the decimal point. Every value is between and .
Output
For each test case, print the smallest possible sample size on its own line.