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$的大小,体积可以负,表面积不能负
 #include <bits/stdc++.h>
using namespace std;
const double PI = acos(-);
double FUCK(double z) {
return PI*(*z + *sin(z) + z/ + sin(*z)/);
}
double f(double z) {
double tmp = *PI*( + cos(z))*sqrt( + sin(z)*sin(z));
return tmp;
}
double simpson(double a,double b,int n = ) {
const double h = (b - a)/n;
double ans = f(a) + f(b);
for(int i = ; i < n; i += ) ans += *f(a+i*h);
for(int i = ; i < n; i += ) ans += *f(a+i*h);
return ans*h/;
}
int main() {
double z1,z2;
int kase;
scanf("%d",&kase);
while(kase--) {
scanf("%lf%lf",&z1,&z2);
double v = FUCK(z2) - FUCK(z1);
double ss = PI*( + cos(z1))*( + cos(z1));
if(z1 > z2) swap(z1,z2);
double s = simpson(z1,z2) + ss;
printf("%.10f %.10f\n",v,s);
}
return ;
}

最新文章

  1. RecyclerView 的介绍以及多布局的实例
  2. LeetCode之344. Reverse String
  3. Microsoft Azure Project Oxford 体验
  4. BZOJ 1858 线段树
  5. Android—Work—1day
  6. LoadRunner如何监控Tomcat性能
  7. ss命令
  8. springmore-让编程更容易
  9. Spring学习笔记之Bean的实例化
  10. C#中的预处理器指令
  11. ui线程和后台线程异步
  12. VS2008 快捷键大全--------&lt;&lt;转&gt;&gt;
  13. API Hook完全手册
  14. wlan0 Interface doesn&#39;t support scanning : Device or resource busy
  15. EasyUI - Messager消息框
  16. synchronized关键字以及实例锁 类锁
  17. auxblogcms1.0.6|代码审计
  18. jquery promise (Deferred)
  19. SaltStack salt-ssh 用法
  20. CentOS下的强大的绘图工具 pinta

热门文章

  1. css bug(ie6兼容问题)
  2. 微信小程序之商品发布+编辑功能(多图片上传功能)
  3. 记一次Oracle冷备恢复的过程
  4. mysql复制数据
  5. 【PostgreSQL-9.6.3】临时表
  6. [Windows Server 2012] 安装PHP+MySQL方法
  7. 【技术累积】【线】【java】【2】AOP
  8. HDU_1027_Ignatius and the Princess II_全排列
  9. acedinitget
  10. Josephus problem(约瑟夫问题,丢手绢问题)