Problem Description
JYC is a fool guy. He is going to give a lesson to the ACM team members.
This lesson is about calculus. He gives a classics example of calculus to the ACMers.
The problem is to calculate the volume of the intersected part of the three same cylinders which are vertical to each other. But as a fool guy, he always forgets something, thus when he wants to show his skills of calculus, he forgets how to figure out the problem. Fortunately, Arios is good at maths, so he tells the fool guy "let me show you what is calculus!". Quickly, Arios finishes.
Everyone in this contest must have learned calculus. Can you solve it by using calculus or other mathematic knowledge?
This lesson is about calculus. He gives a classics example of calculus to the ACMers.
The problem is to calculate the volume of the intersected part of the three same cylinders which are vertical to each other. But as a fool guy, he always forgets something, thus when he wants to show his skills of calculus, he forgets how to figure out the problem. Fortunately, Arios is good at maths, so he tells the fool guy "let me show you what is calculus!". Quickly, Arios finishes.
Everyone in this contest must have learned calculus. Can you solve it by using calculus or other mathematic knowledge?
Input
There are multiple test cases. The first line contains an integer T (T<=100), indicates the test cases.
Next T line follow. There will be 2 floating numbers r and h (0<2r<=h<=10000) per line. r indicates the the radius of a cylinder, and h indicates the height. Remember that three cylinders are totally same.
Next T line follow. There will be 2 floating numbers r and h (0<2r<=h<=10000) per line. r indicates the the radius of a cylinder, and h indicates the height. Remember that three cylinders are totally same.
Output
For each test case, output "Case #D: " first, D is the test case number. Then following a floating number (round to 0.001) which is the volume of the intersected part of the three cylinders.
Sample Input
2 5.00 20.00 30.00 110.00
Sample Output
Case #1: 585.786 Case #2: 126529.871
积分 高数是个渣
帮锐神友情链接http://ray007great.hostyd.com/2013/07/hdu_04/
#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;
int main()
{
int t;
int cnt=1;
cin>>t;
while(t--)
{
double R,H;
cin>>R>>H;
printf("Case #%d: %.3lf\n",cnt++,8*(2-sqrt(2))*R*R*R);
}
return 0;
}