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$的大小,体积可以负,表面积不能负
#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 ;
}
ZOJ 5579 Stean的更多相关文章
- ZOJ 3898 - Stean 积分
有一个陶罐,陶罐是由函数Y=2+cosX,截取x=Z1到x=Z2段后,形成的旋转体,陶罐只有底x=Z1,没有盖子. 问陶罐能乘多少的水(体积),以及它的表面积 体积还是比较好求的,直接用旋转体体积公式 ...
- ZOJ People Counting
第十三届浙江省大学生程序设计竞赛 I 题, 一道模拟题. ZOJ 3944http://www.icpc.moe/onlinejudge/showProblem.do?problemCode=394 ...
- ZOJ 3686 A Simple Tree Problem
A Simple Tree Problem Time Limit: 3 Seconds Memory Limit: 65536 KB Given a rooted tree, each no ...
- ZOJ Problem Set - 1394 Polar Explorer
这道题目还是简单的,但是自己WA了好几次,总结下: 1.对输入的总结,加上上次ZOJ Problem Set - 1334 Basically Speaking ac代码及总结这道题目的总结 题目要求 ...
- ZOJ Problem Set - 1392 The Hardest Problem Ever
放了一个长长的暑假,可能是这辈子最后一个这么长的暑假了吧,呵呵...今天来实验室了,先找了zoj上面简单的题目练练手直接贴代码了,不解释,就是一道简单的密文转换问题: #include <std ...
- ZOJ Problem Set - 1049 I Think I Need a Houseboat
这道题目说白了是一道平面几何的数学问题,重在理解题目的意思: 题目说,弗雷德想买地盖房养老,但是土地每年会被密西西比河淹掉一部分,而且经调查是以半圆形的方式淹没的,每年淹没50平方英里,以初始水岸线为 ...
- ZOJ Problem Set - 1006 Do the Untwist
今天在ZOJ上做了道很简单的题目是关于加密解密问题的,此题的关键点就在于求余的逆运算: 比如假设都是正整数 A=(B-C)%D 则 B - C = D*n + A 其中 A < D 移项 B = ...
- ZOJ Problem Set - 1001 A + B Problem
ZOJ ACM题集,编译环境VC6.0 #include <stdio.h> int main() { int a,b; while(scanf("%d%d",& ...
- zoj 1788 Quad Trees
zoj 1788 先输入初始化MAP ,然后要根据MAP 建立一个四分树,自下而上建立,先建立完整的一棵树,然后根据四个相邻的格 值相同则进行合并,(这又是递归的伟大),逐次向上递归 四分树建立完后, ...
随机推荐
- 利用【监听器】动态加载Log4j配置文件
转自:https://veromca273.iteye.com/blog/1889304 1 创建监听器: public class LogListener implements ServletCon ...
- JavaScript--显示和隐藏(display属性)
网页中经常会看到显示和隐藏的效果,可通过display属性来设置. 语法: Object.style.display = value 注意:Object是获取的元素对象,如通过document.get ...
- 最近几道hihocode不会做的题目
几个易错点 1.数据范围一定要开大,一般多开10个或者5个. 2. 从经常写 int a[n], 然后访问a[n], 这显然会下标越界. 3. 浮点数,无法精确的比较,等于,大于,小于, 都需要使用e ...
- Android 签名(5)用命令签名和用android studio,eclipse签名
1,用命令签名 无论用哪个 IDE 开发,最终只是用了 keytool 和 jarsigner 这两个 Java 工具来完成签名任务(在 jdk 的 bin 目录下).其中 keytool 用来生成 ...
- 笔记《精通css》第4章 背景图像,平铺方式,背景定位,圆角框,投影,不透明
第4章 背景图像,平铺方式,背景定位,圆角框,投影,不透明 1.背景图像 background-image:url() 2.平铺方式 background-repeat:repeat-x repea ...
- UVM基础之--------uvm_root
uvm_root 是uvm的顶层实例扮演了一个top-level and phase controller 的作用,对于component来说.该类不需要用户实例化,他是一个自动实例化了的类,用户直接 ...
- JS——样式类的添加
1.注意current前有个空格 this.className = this.className + " current"; 2.直接将class所有的值替换成current th ...
- js 零碎
function具有一个属性是length,表示希望接收到的命名参数的个数.可以通过arguments获取参数.arguments.callee表示函数本身,递归时有用,也可以通过arguments. ...
- MyEclipse中VSS的使用详解
本文系转载,原文地址http://hi.baidu.com/yi88cheng/blog/item/13dd862f765e6b5c4fc226e5.html
- java_servlet执行流程和生命周期