training diary 2011-01-22
This is the second day of this winter holiday.
I know I must do a lot in this winter holiday ,so I go back to school ,in the training room, I would have a better efficency!
details:
1)
00:00 regist the codeforce #52 , but it is a long time since last coding, so I am in very bad condition.Firstly,i didn't read the problem correctly, wa 3 times, I got the ac 30 minutes after the match started.I passed the pretest of problem B at 50mins, but it failed the final test after the contest.It was because when debuging,I found a small mistake and corrected it,but this sentence appeared two times,I didn't correct the other one,so....
Then ,I spent the last 1 hour in problem E,but there is something wrong with my IDE(both netbeans and Eev),I can't debug the long codes,then the contest ended...
1.尽快恢复状态 2.提升代码习惯 3.重整系统
2)I went back to school in the afternoon,then I found some problems on poj ,1579 is a simple problem,you could finish by both recursion and dp,but 注意题目的优先计算顺序。先是考虑是否会小于0,然后才考虑是否会大于20,要不然就会WA。(害得我wa了一下午,555)
我来到博客园了!
首先批评一下博客园没有自动保存草稿的功能,刚才插入代码导致页面崩溃,写好多文章没有了,不过以后技术文章一定不会直接用网页写的。
来到博客园的原因很简单:
1.原来的空间在百度,可惜百度对于写代码的支持太差,不仅没有插入代码功能,连tab都不支持;
2.百度空间现在在向sns方向发展,最近搞出了搭讪等等应用,主页变得太难看,实在受不了啊!
以后认真学习编程,多写文章!
void main(){ puts("I love programming!"); }
一种ws的计算几何方法
http://poj.org/problem?id=3737
题意:给出圆锥的表面积(包含底面的圆),求圆锥的最大体积,并输出高与半径
常规思路:
推公式:
S=pi*r*l + pi*r*r
l=sqrt(r*r+h*h),
联立得, r*2= s*s/(pi*pi*h*h+2*pi*s)
V=(1/3)*pi*r*r*h,
代入r*2,求导,令一阶导数为0,
得出结果h=sqrt(2*s/pi)
r=sqrt(s*s/(pi*pi*h*h+2*pi*s))
把h代到r里面,可以得到r=sqrt(s/pi/4)
v=(1.0/3.0)*(s*s)*h/(pi*h*h+2*s)
其他思路:
直接二分f'(x)=0
left=0.0right=sqrt(s/2pi)...
ws思路:
先用excel暴力(三分搜索)出样例的一个比较精确的解:
v=10.9254843059207
h=4.37019320246246
s=1.5450969
设输入的数是样例的d*d倍(也就是把样例等比例放大d倍)
v'=v*d*d*d
h'=h*d
s'=s*d
比赛的时候忘记求导公式原来可以用这种ws的方法^_^
ps:可能因为这题数据范围小(1≤S≤10000)而且输出精读要求低(0.01)吧
注意:
1.pi用 #define PI acos(double(-1)) 比较稳妥,有人pi到了15位ac
2.printf 把%.2f改成%.2lf可能就过了
3.我用%.2lf g++ wa 然而 c++ ac
用%.2f g++ c++都ac了