当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

2598:Match Throwing Game

题目描述
There is a very simple but interesting game. In this game we have a match and a table with some parallel lines on it (as shown in the figure). We have known that the distance between two neighboring lines on the table are all 1 and the length of the match is L. For the match is very thin, we ignore the width of the match, and treat the match as a line segment. Then we throw the match for 1000 times, sometimes the match will intersect with lines (the case that one ending point of the match is on the lines is also treated as intersecting), and sometimes not. When throwing, we count how many times the match intersects with the lines (we use P to record the number of intersecting cases). You job is to calculate the most probable value of P.

Why this game is interesting? Let's take L = 0.5 for example, in this case, P will be 318. 1000 / 318 = 3.14..., do you see something interesting?
输入解释
The input consists of many test cases. Each case contains a float number L (0 < L < 10) in a single line.
输出解释
For each case, output P in a single line.
输入样例
0.5
1.21
输出样例
318
718

该题目是Virtual Judge题目,来自 北京大学POJ

源链接: POJ-2598

最后修改于 2020-10-29T06:36:43+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
1000 65536