codeforces 280,281(Round #172)题解
来源:互联网 发布:淘宝日本化妆品代购 编辑:程序博客网 时间:2024/05/01 23:52
2A:没什么可说的,大水题
2B:这个很郁闷,朴素的模拟,但是比赛时忘了精度问题挂了,桑心>_<,也是水题,我是通分然后模拟做的。但是强大的py直接由函数,郁闷T_T
2C(1A):平几题,唯一麻烦的是由两种情况,一种是有几个三角形的,另一种是只存在平行四边形,邻接情况需要计算。(据说正解是半平面交?不清楚)我设的是两种三角形的斜边长,解二元一次方程,上代码:
#include<cstdio>#include<iostream>#include<algorithm>#include<queue> #include<cmath> using namespace std;const long double Pi=3.1415926535897932384626433832795028841971; //x(1+cosa)+ysina=w //y(1+cosa)+asina=hint main(){ long double w,h,a; long double ans; cin>>w>>h>>a; if(w<h) swap(w,h); if(a>90) a=180-a; if(a==90) { ans=min(w,h)*min(w,h); cout.precision(9); cout<<fixed<<ans<<endl;return 0; } double hu=a*Pi/180; if(tan(hu)*(w*w-h*h)<2*w*h) //八边形 { long double m=1.0+cos(hu); long double n=sin(hu); long double x,y; x=(m*w-n*h)/(m*m-n*n); y=(m*h-n*w)/(m*m-n*n); ans=w*h-x*x/2*sin(2*hu)-y*y/2*sin(2*hu); } else { ans=h*h/sin(hu); } cout.precision(9); cout<<fixed<<ans<<endl; return 0; }2D(1B):这题很水,主要到只需要最大和次大,很容易想到单调栈,每次入栈元素是X的时候,把栈中比x小的边弹栈边计算,因为后面一定用不到,比x大的计算但不弹栈,因为后面会用到,这样做即可。
2E(1C):个人觉得这道题很难,想了好久。我们最后要计算的是E(总操作次数)=sigma{E([每个结点u是因为选中了自己而删去的])},两者相等的原因是他们包含了所有情况。而每个节点u是因为选中自己被删去还是因为选中祖先被删去,与其他链无关,只与自己在树中的深度有关,于是结论出来了,个点深度的倒数和即为答案,好题!
- codeforces 280,281(Round #172)题解
- Codeforces Round #436 (Div. 2) (题解)
- codeforces Round #180题解
- Codeforces Round #334 题解
- Codeforces Round #366 题解
- Codeforces Round #397 题解
- Codeforces Round #424 题解
- Codeforces Round #433 题解
- Codeforces Round #434 题解
- Codeforces Round #438 题解
- Codeforces Round #438 题解
- Codeforces Round #432 题解
- codeforces 282(Round #173)题解
- codeforces 1(Round #1)题解
- codeforces 285(Round #175)题解
- codeforces 286(Round #176)题解
- codeforces round 169 div2 题解
- codeforces 295(Round #179)题解
- 扩展Js startWith函数,类似Java中的startsWith
- zip 解压多个文件
- 5个Ajax最佳实践
- 使用Set Factory2
- HBase Java 控制-1
- codeforces 280,281(Round #172)题解
- Skype和MSN联姻了
- 信用卡交易流程
- 模板方法模式(TemplateMethod)
- unity3d 带缓冲的镜头拉近效果
- qt 开发
- javascript中获取当前鼠标的坐标
- 28个Unix/Linux的命令行神器
- Coreutils - GNU core utilities