ZOJ 5579 Stean

Stean


Time Limit: 1 Second      Memory Limit: 65536 KB      Special Judge


Tom is good at making stean, he can make steans of various color and shape. Now he want to know how many water it can contain, and how many material he need to making a stean.

The shape of the stean follows rules below:

1. The horizontal projection is a circle. The front projection contains two cosine curve. Tom can pour water from the top of stean.

2.To describe it more clearly, Tom constructs a cylindrical coordinate system. Tom is a strange person, because if there no stean at all when Z1 is equal to Z2, he still asks you. Tom tells you origin of coordinates is on the axis of cylinder , Z-axis is the axis of cylinder. And he measures that the height of undersurface Z1 and the height of upsurface of the stean Z2. And he find the formula of cosine curve is R = 2 + cos(Z).Here R is the inner circle‘s radius.

Now you need to tell him the capacity and the area of internal surface, which are in direct proportional to water tank capacity and material needed. You need to be precise to two digits after float point.

Input

The first line of the input contains a single integer T (1 <= T <= 300), which denotes the number of test cases. Then each line contains a case, consisted by a pair of integer numbers Z1 and Z2 (|Z1| <= 1000.00, |Z2| <= 1000.00). They are separated by a space.

Output

There are T lines, each line contains a floating point number, the capacity and the area of internal surface. An answer with absolute error less than 10-2 or with relative error less than 10-5 will be accepted.

Sample Input

2
0 3.14159
-0.0001 0.0

Sample Output

44.41 76.28
0.00 28.27


Author: WANG, Xinglu

解题:直接积分,注意$Z_1 与 Z_2$的大小,体积可以负,表面积不能负

 1 #include <bits/stdc++.h>
 2 using namespace std;
 3 const double PI = acos(-1);
 4 double FUCK(double z) {
 5     return PI*(4*z + 4*sin(z) + z/2 + sin(2*z)/4);
 6 }
 7 double f(double z) {
 8     double tmp = 2*PI*(2 + cos(z))*sqrt(1 + sin(z)*sin(z));
 9     return tmp;
10 }
11 double simpson(double a,double b,int n = 10000) {
12     const double h = (b - a)/n;
13     double ans = f(a) + f(b);
14     for(int i = 1; i < n; i += 2) ans += 4*f(a+i*h);
15     for(int i = 2; i < n; i += 2) ans += 2*f(a+i*h);
16     return ans*h/3;
17 }
18 int main() {
19     double z1,z2;
20     int kase;
21     scanf("%d",&kase);
22     while(kase--) {
23         scanf("%lf%lf",&z1,&z2);
24         double v = FUCK(z2) - FUCK(z1);
25         double ss = PI*(2 + cos(z1))*(2 + cos(z1));
26         if(z1 > z2) swap(z1,z2);
27         double s = simpson(z1,z2) + ss;
28         printf("%.10f %.10f\n",v,s);
29     }
30     return 0;
31 }

时间: 2024-08-05 08:42:18

ZOJ 5579 Stean的相关文章

ZOJ 3898 - Stean 积分

有一个陶罐,陶罐是由函数Y=2+cosX,截取x=Z1到x=Z2段后,形成的旋转体,陶罐只有底x=Z1,没有盖子. 问陶罐能乘多少的水(体积),以及它的表面积 体积还是比较好求的,直接用旋转体体积公式,pi*∫[z1,z2](2+cosX)2dX=  pi* ( 4sinX+sin2X/4+9X/2 | [z1,z2] ) 比较难求的是表面积,套用旋转体侧面积公式,2pi*∫[z1,z2](2+cosX)*sqrt(1+sin2X)dX 然而这个积分相当难求(好像是第二类椭圆积分),我们需要用辛

ZOJ 3898 Stean 矩形法求积分

题目链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=5601 题意:求一个绕y轴旋转的旋转体体积.R = 2+cos(z). 思路:旋转体体积可以直接用积分求出来,旋转体表面积公式对于此题积分比较难积,所以用矩形法来求积分. 1 #include <bits/stdc++.h> 2 using namespace std; 3 int T; 4 double z1, z2, V, area; 5 const doubl

概率dp ZOJ 3640

Help Me Escape Time Limit:2000MS     Memory Limit:32768KB     64bit IO Format:%lld & %llu Submit Status Practice ZOJ 3640 Appoint description:  System Crawler  (2014-10-22) Description Background     If thou doest well, shalt thou not be accepted? an

zoj 2156 - Charlie&#39;s Change

题目:钱数拼凑,面值为1,5,10,25,求组成n面值的最大钱币数. 分析:dp,01背包.需要进行二进制拆分,否则TLE,利用数组记录每种硬币的个数,方便更新. 写了一个 多重背包的 O(NV)反而没有拆分快.囧,最后利用了状态压缩优化 90ms: 把 1 cents 的最后处理,其他都除以5,状态就少了5倍了. 说明:貌似我的比大黄的快.(2011-09-26 12:49). #include <stdio.h> #include <stdlib.h> #include <

ZOJ 1718 POJ 2031 Building a Space Station 修建空间站 最小生成树 Kruskal算法

题目链接:ZOJ 1718 POJ 2031 Building a Space Station 修建空间站 Building a Space Station Time Limit: 2 Seconds      Memory Limit: 65536 KB You are a member of the space station engineering team, and are assigned a task in the construction process of the statio

ZOJ 3607 Lazier Salesgirl (贪心)

Lazier Salesgirl Time Limit: 2 Seconds      Memory Limit: 65536 KB Kochiya Sanae is a lazy girl who makes and sells bread. She is an expert at bread making and selling. She can sell the i-th customer a piece of bread for price pi. But she is so lazy

ZOJ - 2243 - Binary Search Heap Construction

先上题目: Binary Search Heap Construction Time Limit: 5 Seconds      Memory Limit: 32768 KB Read the statement of problem G for the definitions concerning trees. In the following we define the basic terminology of heaps. A heap is a tree whose internal n

ZOJ 2859 二维线段树

思路:自己写的第二发二维线段树1A,哈哈,看来对二维的push操作比较了解了:但是还没遇到在两个线段树中同时进行push操作的,其实这题我是想在x维和y维同时进行push操作的,但是想了好久不会,然后看到这题又给出10秒,然后想想在x维线段直接单点查询肯定也过了,然后在第二维就只有pushup操作,在第一维线段树没有pushup操作.要是在第一维也有pushup操作的话,那就不用单点查询那么慢了.不过也A了,想找题即在二维同时进行pushup和pushdown操作的. #include<iost

ZOJ 2588

求一个无向图的桥(可能存在重边),输出割边的数目,并按顺序输出割边的序号(输入的顺序). 由于内存的限制 , 无法使用邻接矩阵 , 只能用邻接表了 . 第一次用了邻接表,超内存了: 1 #include <iostream> 2 #include <cstdio> 3 #include <algorithm> 4 #include <string.h> 5 using namespace std; 6 const int N=10002; 7 const i