您的位置:首页 > 其它

ZOJ 5579 Stean

2015-09-12 17:29 357 查看
SteanTime 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.

#include <bits/stdc++.h>
using namespace std;
const double PI = acos(-1);
double FUCK(double z) {
return PI*(4*z + 4*sin(z) + z/2 + sin(2*z)/4);
}
double f(double z) {
double tmp = 2*PI*(2 + cos(z))*sqrt(1 + sin(z)*sin(z));
return tmp;
}
double simpson(double a,double b,int n = 10000) {
const double h = (b - a)/n;
double ans = f(a) + f(b);
for(int i = 1; i < n; i += 2) ans += 4*f(a+i*h);
for(int i = 2; i < n; i += 2) ans += 2*f(a+i*h);
return ans*h/3;
}
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*(2 + cos(z1))*(2 + cos(z1));
if(z1 > z2) swap(z1,z2);
double s = simpson(z1,z2) + ss;
printf("%.10f %.10f\n",v,s);
}
return 0;
}


View Code
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: