zoj-3923- In the Rain

Description

Fujiwara no Mokou was formerly an ordinary human, but she became an immortal being after drinking the Hourai Elixir about 1300 years ago. She has some sort of control over fire.
Fujiwara no Mokou

One day, Mokou was on the way home after cutting bamboo. Suddenly it began to rain. As a manipulator of fire, Mokou dislikes rains. So she ran to her home as quickly as possible.

We can regard Mokou as a cylinder. The path can be simplified as a line. Mokou started from (0, 0, 0) and her home is at (x0, 0, 0). It is supposed that the rain is continuous and its density is 1. The rain will be absorbed immediately when it touches the surface of the cylinder or the ground. You need to measure how much weight of rain was absorbed by Mokou during her way to home in the rain.

Input

There are multiple cases. The first line of the input contains an integer T (1 ≤ T ≤ 200) which indicates the number of cases. For each test case:
The first line contains four integers R, H, V, x0, the radius, height and speed of the cylinder and the location of Mokou’s house.
The second line contains three integers dx, dy and dz, the speed of the rain.
All integers in input are no less than -1000 and no larger than 1000. Test data satisfy that R, H, V, x0 > 0, dz < 0.

Output

For each case, output the total weight of rain which was absorbed by Mokou. Absolute or relative error no more than 1E-6 will be accepted.

Sample Input

2
1 1 1 1
0 0 -1
2 3 3 3
2 3 -3

Sample Output

5.1415926536
75.6464437651

Reference

将雨的三个方向的速度合成成 水平的速度和垂直的速度,由于水平的受面永远是2*r*h,并且垂直的受面是2*PI*r*r 根据速度和时间可以求解
我怎么感觉这个是物理题还是数学题呢

#include<iostream>
#include<cstdio>
#include<cmath>
#include <cstring>
#include <algorithm>
using namespace std;

#define PI acos(-1.0)
typedef long long ll;

int main()
{
    int t;
    scanf("%d",&t);
    while(t--)
    {
        double r,h,v,x0,dx,dy,dz;
        scanf("%lf%lf%lf%lf%lf%lf%lf",&r,&h,&v,&x0,&dx,&dy,&dz);
        dz = fabs(dz);dy = fabs(dy);
        double tim = fabs(x0 / v);
        v -= dx;
        v=fabs(v);
        double dxy = sqrt(v * v + dy * dy);
        double sum = dxy * h * 2 * r * tim;
        sum += dz * PI * r * r * tim;
        printf("%.10f\n",sum);

    }
    return 0;
}

你可能感兴趣的:(zoj-3923- In the Rain)