poj——1031——fence
来源:互联网 发布:淘宝真丝布料价格 编辑:程序博客网 时间:2024/06/13 02:11
address:http://poj.org/problem?id=1031
My thought:说实话 看见英语题的时候 状态不咋好,后来勉强把题目看完。
不是太懂,想了好久,题目根本通不了,这英语太菜让我无语,我去度了一下,有的解法是用积分,有的说这是一道很水的题目。
我大概都看了看,有一些代码 提示错误,下面这个代码是可以用的。 题目中有一部分不是太懂,如果哪位朋友看懂了,可以留下言,谢谢。
#include<iostream>#include<cmath>#include<iomanip>#include<algorithm>using namespace std;#define max(a,b) ((a)>(b)?(a):(b)) #define min(a,b) ((a)<(b)?(a):(b))const double PI=3.1415926535;struct Point{double x,y;};Point point[205];double beta(int k){//double result=(point[k].x)*(point[k+1].y)-(point[k+1].x)*(point[k].y);double a=sqrt(point[k].x*point[k].x+point[k].y*point[k].y);//点到原点的长度double deg1=acos(point[k].x/a);//与X轴的夹角if(point[k].y<0)deg1=2*PI-deg1;//求角的时候求出的是与X轴正半轴的夹角,如果在X轴下面,求出的角大小就是2*pi-这个角double b=sqrt(point[k+1].x*point[k+1].x+point[k+1].y*point[k+1].y);double deg2=acos(point[k+1].x/b);if(point[k+1].y<0)deg2=2*PI-deg2;double ans=deg2-deg1;if(ans>=PI)ans-=2*PI;else if(ans<=-PI)ans+=2*PI;return ans;}int main(){double k,h;int n,i;double angle,maximum,minimum,answer;while(cin>>k>>h>>n){for(i=0;i<n;i++)cin>>point[i].x>>point[i].y;angle=0;maximum=0;minimum=0;point[n]=point[0];for(i=0;i<n;i++){angle+=beta(i);maximum=max(maximum,angle);minimum=min(minimum,angle);}angle=max(angle,-angle);if(fabs(angle-2*PI)<1e-4)answer=2*PI;else{answer=maximum-minimum;if(answer>2*PI)answer=2*PI;};answer*=k*h;cout<<fixed<<setprecision(2)<<answer<<endl;//system("pause");}return 0;}
- poj——1031——fence
- poj——A decorative fence
- 刷题——Fence Repair POJ
- Poj3253—Fence Repair
- POJ—3253—Fence Repair—【贪心】【优先队列】
- POJ——3253 Fence Repair(优先队列)
- POJ 3253 Fence Repair(贪心—霍夫曼树or优先队列)
- poj3253——Fence Repair
- POJ3253——Fence Repair
- POJ3253——Fence Repair
- poj3253——Fence Repair
- android graphic(15)—fence
- POJ 1031 Fence
- POJ 1031 Fence 笔记
- POJ 1031--Fence
- 【优先队列/huffman】sdut 2848/poj 3253——Fence Repair
- POJ 3253 Fence Repair——优先队列 用long long或__int64才能过
- USACO算法系列十四——fence
- C Primer Plus 5th 翻译 第四章:字符串和格式化输入/输出(二)
- KDTable 表达式应用工具类
- 深度解析Java内存的原型及工作原理
- Autoit和AutoHotKey自动运行程序脚本
- 在程序被送入后台时,向 iOS 借点时间,来完成一个长期任务
- poj——1031——fence
- 优秀IT技术文章集(最新)(高质量)
- Hdu 2577 How to Type
- poj 3159 -- Candies ( spfa + 栈 )
- ubuntu12.04系统下firefox利用goagent+foxy proxy Cross the GFW教程
- 第一个struts2程序
- ns2.35错误
- 一维数组的初始化问题
- 不开辟用于交换数据的临时空间,如何完成字符串的逆序