#P13456. [GCJ 2008 Qualification] Fly Swatter

    ID: 15331 远端评测题 6000ms 1024MiB 尝试: 0 已通过: 0 难度: 5 上传者: 标签>数学计算几何2008Special JudgeGoogle Code Jam

[GCJ 2008 Qualification] Fly Swatter

题目描述

What are your chances of hitting a fly with a tennis racquet?

To start with, ignore the racquet's handle. Assume the racquet is a perfect ring, of outer radius RR and thickness tt (so the inner radius of the ring is RtR - t).

The ring is covered with horizontal and vertical strings. Each string is a cylinder of radius rr. Each string is a chord of the ring (a straight line connecting two points of the circle). There is a gap of length gg between neighbouring strings. The strings are symmetric with respect to the center of the racquet i.e. there is a pair of strings whose centers meet at the center of the ring.

The fly is a sphere of radius ff. Assume that the racquet is moving in a straight line perpendicular to the plane of the ring. Assume also that the fly's center is inside the outer radius of the racquet and is equally likely to be anywhere within that radius. Any overlap between the fly and the racquet (the ring or a string) counts as a hit.

输入格式

One line containing an integer NN, the number of test cases in the input file.

The next NN lines will each contain the numbers ff, RR, tt, rr and gg separated by exactly one space. Also the numbers will have exactly 6 digits after the decimal point.

输出格式

NN lines, each of the form "Case #kk: PP", where kk is the number of the test case and PP is the probability of hitting the fly with a piece of the racquet.

Answers with a relative or absolute error of at most 10610^{-6} will be considered correct.

5
0.250000 1.000000 0.100000 0.010000 0.500000
0.250000 1.000000 0.100000 0.010000 0.900000
0.000010 10000.000000 0.000010 0.000010 1000.000000
0.400000 10000.000000 0.000010 0.000010 700.000000
1.000000 100.000000 1.000000 1.000000 10.000000
Case #1: 1.000000
Case #2: 0.910015
Case #3: 0.000000
Case #4: 0.002371
Case #5: 0.573972

提示

  • ff, RR, tt, rr and gg will be positive and smaller or equal to 10000.
  • t<Rt < R
  • f<Rf < R
  • r<Rr < R

Small dataset (5 Pts, Test set 1 - Visible)

  • 1N301 \leq N \leq 30
  • The total number of strings will be at most 60 (so at most 30 in each direction).

Large dataset (20 Pts, Test set 2 - Hidden)

  • 1N1001 \leq N \leq 100
  • The total number of strings will be at most 2000 (so at most 1000 in each direction).