POJ - 1266 -
题目大意:给出一条圆弧上的两个端点A,B,和圆弧上两端点之间的一个点C,现在要用一块各个定点的坐标均为整数的矩形去覆盖这个圆弧,要求最小的矩形面积。
#include <iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<stdlib.h>
#include<vector>
#include<cmath>
#include<queue>
#include<set>
using namespace std;
#define N 100000
#define LL long long
#define INF 0xfffffff
const double eps = 1e-;
const double pi = acos(-1.0);
const double inf = ~0u>>;
struct Point
{
double x,y;
Point(double x=,double y=):x(x),y(y) {}
}p[];
typedef Point pointt;
pointt operator + (Point a,Point b)
{
return Point(a.x+b.x,a.y+b.y);
}
pointt operator - (Point a,Point b)
{
return Point(a.x-b.x,a.y-b.y);
}
int dcmp(double x)
{
if(fabs(x)<eps) return ;
else return x<?-:;
}
struct Circle
{
Point center;
double r;
};
double cross(Point a,Point b)
{
return a.x*b.y-a.y*b.x;
}
double mul(Point p0,Point p1,Point p2)
{
return cross(p1-p0,p2-p0);
}
double dis(Point a)
{
return a.x*a.x+a.y*a.y;
}
double area()
{
return fabs(cross(p[]-p[],p[]-p[]))/;
}
bool seginter(pointt a1,pointt a2,pointt b1,pointt b2)
{
double c1 = cross(a2-a1,b1-a1),c2 = cross(a2-a1,b2-a1),
c3 = cross(b2-b1,a1-b1),c4 = cross(b2-b1,a2-b1);
return dcmp(c1)*dcmp(c2)<&&dcmp(c3)*dcmp(c4)<;
}
struct Circle Circumcircle()
{
Circle tmp;
double a,b,c,c1,c2;
double xa,ya,xb,yb,xc,yc;
a = sqrt(dis(p[]-p[]));
b = sqrt(dis(p[]-p[]));
c = sqrt(dis(p[]-p[]));
tmp.r = (a*b*c)/(area()*4.0);
xa = p[].x;
ya = p[].y;
xb = p[].x;
yb = p[].y;
xc = p[].x;
yc = p[].y;
c1 = (dis(p[])-dis(p[]))/;
c2 = (dis(p[])-dis(p[]))/;
tmp.center.x = (c1*(ya-yc)-c2*(ya-yb))/((xa-xb)*(ya-yc)-(xa-xc)*(ya-yb));
tmp.center.y = (c1*(xa-xc)-c2*(xa-xb))/((ya-yb)*(xa-xc)-(ya-yc)*(xa-xb));
return tmp;
}
int main()
{
int i;
double r;
int w0,w1,h0,h1;
for(i = ; i <= ; i++)
scanf("%lf%lf",&p[i].x,&p[i].y);
Circle cc = Circumcircle();
r = cc.r; Point q[];
for(i = ;i < ;i++)
q[i] = cc.center;
q[].x-=r,q[].x+=r,q[].y-=r,q[].y+=r; if(!seginter(q[],p[],p[],p[])) w0 = floor(q[].x+eps);
else w0 = floor(min(p[].x,p[].x)+eps); if(!seginter(q[],p[],p[],p[])) w1 = ceil(q[].x-eps);
else w1 = ceil(max(p[].x,p[].x)-eps); if(!seginter(q[],p[],p[],p[])) h0 = floor(q[].y+eps);
else h0 = floor(min(p[].y,p[].y)+eps); if(!seginter(q[],p[],p[],p[])) h1 = ceil(q[].y-eps);
else h1 = ceil(max(p[].y,p[].y)-eps); printf("%d\n",(h1-h0)*(w1-w0));
return ;
}
POJ - 1266 -的更多相关文章
- poj 1266 Cover an Arc.
http://poj.org/problem?id=1266 Cover an Arc. Time Limit: 1000MS Memory Limit: 10000K Total Submiss ...
- POJ题目细究
acm之pku题目分类 对ACM有兴趣的同学们可以看看 DP: 1011 NTA 简单题 1013 Great Equipment 简单题 102 ...
- 【转】POJ百道水题列表
以下是poj百道水题,新手可以考虑从这里刷起 搜索1002 Fire Net1004 Anagrams by Stack1005 Jugs1008 Gnome Tetravex1091 Knight ...
- POJ 3370. Halloween treats 抽屉原理 / 鸽巢原理
Halloween treats Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 7644 Accepted: 2798 ...
- POJ 2356. Find a multiple 抽屉原理 / 鸽巢原理
Find a multiple Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 7192 Accepted: 3138 ...
- POJ 2965. The Pilots Brothers' refrigerator 枚举or爆搜or分治
The Pilots Brothers' refrigerator Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 22286 ...
- POJ 1753. Flip Game 枚举or爆搜+位压缩,或者高斯消元法
Flip Game Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 37427 Accepted: 16288 Descr ...
- POJ 3254. Corn Fields 状态压缩DP (入门级)
Corn Fields Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 9806 Accepted: 5185 Descr ...
- POJ 2739. Sum of Consecutive Prime Numbers
Sum of Consecutive Prime Numbers Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 20050 ...
随机推荐
- CSS —— 选择器
选择器种类 标签选择器 id选择器 类选择器 通配符 交集选择器 并集选择器 后代选择器 子代选择器 选择器设置样式优先级 默认样式 < 继承样式 < 通配符设置样式 < 标签选择器 ...
- WPF GridView的列宽度设置为按比例分配
<Grid> <Grid> <Grid.ColumnDefinitions> <ColumnDefinition Width="3*" / ...
- 如何手动删除服务?Windows手动删除服务列表中残留服务的方法
https://www.jb51.net/os/windows/267738.html
- EXT3.3.1在IE9 IE10click事件 失效怎么解决
各位Ext君有福了. var treePanel = new Ext.tree.TreePanel({ id:'treePanel_'+(menuIndex++),//让菜单id可控 title: t ...
- 移动端中遇到的坑(bug)!!!
1.模拟单选点击的时候,在ios手机下,点击下面的内容选择,会出现页面闪一闪!! 解决方案:样式重置html的时候加上这句 -webkit-tap-highlight-color: rgba(0, ...
- C#实现图片叠加,图片上嵌入文字,文字生成图片的方法
/// <summary> /// 图片叠加 /// </summary> /// <param name="sender"& ...
- TortoiseSVN常用配置
在Windows下推荐使用乌龟(Tortoise)SVN客户端. TortoiseSVN 是 Subversion 版本控制系统的一个免费开源客户端,可以超越时间的管理文件和目录. 文件保存在中央版本 ...
- unbuntu中如何像Windows一样顺畅的切换中英文输入法
1.首先在unbuntu安装搜狗拼音输入法(这个不用教了) 2.点击右上角的搜狗拼音的图标点击设置进入设置页面 3.选择高级 4.选择Fcitx设置 5.添加输入法英语(美国) 6.在设置中选择按键, ...
- 005_awk案例实战
一.工作经验总结. (1)日志案例: 10.100.194.39 10.100.194.39 1019-03-16T11:01:04+08:00 www.uuwatch.com^^3FF91DE01B ...
- 故障 -> nginx启动失败
描述:在用saltstack给 minion 安装 nginx 服务 时 提示 nginx 服务下载成功,但是启动失败. ---------- ID: nginx-systemctl Function ...