poj 1266 Cover an Arc.
http://poj.org/problem?id=1266
Time Limit: 1000MS | Memory Limit: 10000K | |
Total Submissions: 823 | Accepted: 308 |
Description
Nobody knows why, but the paint on the floor formed an arc of a circle (a centre of the circle lies inside the hall). The dean of the Department of Mathematics and Mechanics measured the coordinates of the arc's ends and of some other point of the arc (he is sure that this information is quite enough for any student of the Ural State University). The dean wants to cover the arc with a rectangular carpet. The sides of a carpet must go along the sides of the mirror plates (so, the corners of the carpet must have integer coordinates).
You should find the minimal square of such a carpet.
Input
Output
Sample Input
476 612
487 615
478 616
Sample Output
66
Source
#include<iostream>
#include<algorithm>
#include<stdio.h>
#define max(a,b) a>b?a:b
#define min(a,b) a>b?b:a
#include<math.h>
using namespace std;
#define eps 1e-8
struct point{double x,y;};
struct line {point a,b;};
point a,b,c;
double xmult(point p1,point p2,point p0){
return (p1.x-p0.x)*(p2.y-p0.y)-(p2.x-p0.x)*(p1.y-p0.y);
}
bool pp(point p)
{
double t1,t2;
t1=(xmult(a,c,b));
t2=(xmult(a,p,b));
if ((t1<&&t2<)||(t1>&&t2>)) return true;
return false;
}
double distan (point p1,point p2)
{
return sqrt((p1.x-p2.x)*(p1.x-p2.x)+(p1.y-p2.y)*(p1.y-p2.y));
}
point inter(line u,line v)
{
point ret = u.a;
double t = ((u.a.x-v.a.x)*(v.a.y-v.b.y)-(u.a.y-v.a.y)*(v.a.x-v.b.x))/((u.a.x-u.b.x)*(v.a.y-v.b.y)-(u.a.y-u.b.y)*(v.a.x-v.b.x));
ret.x +=(u.b.x-u.a.x)*t;
ret.y +=(u.b.y-u.a.y)*t;
return ret;
}
point circle(point a,point b,point c )
{
line u,v;
u.a.x =(a.x+b.x)/;
u.a.y = (a.y+b.y)/;
u.b.x = u.a.x - a.y+b.y;
u.b.y = u.a.y + a.x-b.x;
v.a.x = (a.x+c.x)/;
v.a.y = (a.y+c.y)/;
v.b.x = v.a.x - a.y+c.y;
v.b.y = v.a.y+a.x-c.x;
return inter(u,v);
}
int main()
{
point d,e,p;
int cas =;
while(~scanf("%lf %lf %lf %lf %lf %lf",&a.x,&a.y,&b.x,&b.y,&c.x,&c.y))
{
d = circle(a,b,c);
double bj = distan(d,a);
double maxx,maxy,minx,miny;
double dd=d.x,yy=d.y;
int ax,bx,cx,ay,by,cy;
maxx=max(a.x,b.x);
maxx=max(maxx,c.x);
minx=min(a.x,b.x);
minx=min(minx,c.x);
maxy=max(a.y,b.y);
maxy=max(maxy,c.y);
miny=min(a.y,b.y);
miny=min(miny,c.y);
p.x=d.x-bj;
p.y=d.y;
if(pp(p))
minx=p.x;
p.x=d.x+bj;
if(pp(p))
maxx=p.x;
p.x=d.x;
p.y=d.y-bj;
if(pp(p))
miny=p.y;
p.y=d.y+bj;
if(pp(p))
maxy=p.y;
cx=(long)ceil(maxx-eps)-(long)floor(minx+eps);
cy=(long)ceil(maxy-eps)-(long)floor(miny+eps);
printf("%d\n",cx*cy);
}
return ;
}
poj 1266 Cover an Arc.的更多相关文章
- Ural 1043 Cover the Arc
题目链接:http://acm.timus.ru/problem.aspx?space=1&num=1043 题目大意:一个2000*2000方格坐标,x,y范围都是[-1000,1000]. ...
- POJ - 1266 -
题目大意:给出一条圆弧上的两个端点A,B,和圆弧上两端点之间的一个点C,现在要用一块各个定点的坐标均为整数的矩形去覆盖这个圆弧,要求最小的矩形面积. 思路:叉积在本体发挥很强大的作用.首先求出三个点所 ...
- poj 2376 Cleaning Shifts
http://poj.org/problem?id=2376 Cleaning Shifts Time Limit: 1000MS Memory Limit: 65536K Total Submi ...
- POJ 2528 Mayor's posters
Mayor's posters Time Limit:1000MS Memory Limit:65536KB 64bit IO Format:%I64d & %I64u Sub ...
- 【POJ 2482】Stars in Your Window
http://poj.org/problem?id=2482 线段树扫描线 #include<cstdio> #include<cstring> #include<alg ...
- POJ 2446 最小点覆盖
Chessboard Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 14787 Accepted: 4607 Descr ...
- poj 2446 Chessboard (二分匹配)
Chessboard Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 12800 Accepted: 4000 Descr ...
- POJ 2528 Mayor's posters(线段树区间染色+离散化或倒序更新)
Mayor's posters Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 59239 Accepted: 17157 ...
- Poj(2784),二进制枚举最小生成树
题目链接:http://poj.org/problem?id=2784 Buy or Build Time Limit: 2000MS Memory Limit: 65536K Total Sub ...
随机推荐
- java调用mysql服务做备份与恢复
首先添加mysql的bin到环境变量,这样可以简写部分命令,并且做到不依赖系统mysql的具体安装路径. 重启计算机可以让添加的环境变量在java代码中调用时生效.(cmd中生效但java中调用没有生 ...
- snakebar 的使用
在一次文章阅读的时候,我浏览到一篇文章关于一个新控件的使用,这个控件就是SnakeBar 该控件和Toast控件一样,在程序运行中起着提示的功能. 效果图如下: 代码如下: Snackbar.make ...
- D3.js部署node环境开发
总结一段D3.js部署node环境的安装过程 准备阶段: 首先电脑上要安装node环境,这个阶段过滤掉,如果node环境都不会装,那就别玩基于node环境搞的其他东西了. 搭建环境: 我在自己的F:系 ...
- OOP: One pont of view of OOP与基于算法设计的区别
..摘自<C++网络编程 卷1:运用ACE和模式消除复杂性> <C++ Network Programming Volume 1 Mastering Complexity with ...
- Android 高亮显示文本中的关键字
总结:SpannableString用好,可以各种替换Span来操作各种内容 1.文本关键字高亮关键在于:SpannableString使用 主要就是通过关键字在文本的开始index,结束index来 ...
- css样式表分类、选择器分类、css基础样式
1 . 样式表 Cascading Style Sheet css优势: 内容与表现分离 网页的表现统一,容易修改 丰富的样式,使网页布局更加灵活 减少网页代码量,增加网页的浏览速度,节省 ...
- 细读cow.osg
细读cow.osg 转自:http://www.cnblogs.com/mumuliang/archive/2010/06/03/1873543.html 对,就是那只著名的奶牛. //Group节点 ...
- 【python】安装python第三方库lxml时,遇到问题:[ERROR: 'xslt-config' 不是内部或外部命令,也不是可运行的程序]
一.概述 lxml介绍http://lxml.de/ 二.问题 ERROR: 'xslt-config' 不是内部或外部命令,也不是可运行的程序 三.解决方法 Scrapy在Windows上的安装笔记 ...
- [canvas]用canvas绘制饼状图
折线图之后又来饼状图啦~\(≧▽≦)/~啦啦啦 <!DOCTYPE html> <html lang="en"> <head> <meta ...
- jQuery用法小结
jQuery加载1.$(document).ready()2.添加css样式:单个:$("p").css("color","red"); 多 ...