2014
01-05

# Who will be the HDU-START tonight?

Here goes the Problem:
——————————————————————————————————————————————————-

As the picture shown above, there is funnel upside the container. You can assume the bottom of the container is a square. Initially, there are some water in the funnel, the funnel’s bottom diameter is x, y stands for the top diameter of the water. Z means the height of the water. The container’s height is h, and its bottom is a d*d size square.
The question is: when all the water in the funnel has leaked out, what’s the height of the water in the container?
Tips: The Volume of a frustum of a cone(圆台) is:,s1 and s2 are the area of the 2 faces, and H is the height.

There will be multiple input sets. Input for each set is five positive integers x, y, z, h and d(x<y, 1<=x, y, z, h, d <= 10000) . The final input set is followed by a line containing five 0s, indicating end of input.

There will be multiple input sets. Input for each set is five positive integers x, y, z, h and d(x<y, 1<=x, y, z, h, d <= 10000) . The final input set is followed by a line containing five 0s, indicating end of input.

1 2 1 3 3
0 0 0 0 0

0.204

#include <iostream>
#include <cstring>
#include <cstdio>
#include <cmath>
using namespace std;
#define PI acos(-1.0)
double calc(int d)
{
double res;
res=PI*(d*.5)*(d*0.5);
return res;
}
int main()
{
int x,y,z,h,d;
while (cin>>x>>y>>z>>h>>d)
{
if (x==0&&y==0&&z==0&&h==0&&d==0)
break;
double s1=calc(x);
double s2=calc(y);
double vc=1.0/3.0*(s1+sqrt(s1*s2)+s2)*z*1.0;
double s=d*1.0*d*1.0;
double ans=vc/s;
if (ans
printf("%.3lf\n",ans);
else
printf("%.3lf\n",h*1.0);
}
return 0;
} 

1. 我没看懂题目
2
5 6 -1 5 4 -7
7 0 6 -1 1 -6 7 -5
我觉得第一个应该是5 6 -1 5 4 输出是19 5 4
第二个是7 0 6 -1 1 -6 7输出是14 7 7
不知道题目例子是怎么得出来的

2. if(j){
int ans=a ;
for(int x=j-1;x>=0;x–){
if(!a ) break;
ans=min(ans,a );
sum+=ans;
}
}
求解释，，dp的思路是什么呢？

3. 一开始就规定不相邻节点颜色相同，可能得不到最优解。我想个类似的算法，也不确定是否总能得到最优解：先着一个点，随机挑一个相邻点，着第二色，继续随机选一个点，但必须至少有一个边和已着点相邻，着上不同色，当然尽量不增加新色，直到完成。我还找不到反例验证他的错误。。希望LZ也帮想想, 有想法欢迎来邮件。谢谢

4. 可以根据二叉排序树的定义进行严格的排序树创建和后序遍历操作。如果形成的排序树相同，其树的前、中、后序遍历是相同的，但在此处不能使用中序遍历，因为，中序遍历的结果就是排序的结果。经在九度测试，运行时间90ms，比楼主的要快。