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 ...
随机推荐
- 源码解析-Volley(转自codeKK)
Volley 源码解析 本文为 Android 开源项目源码解析 中 Volley 部分项目地址:Volley,分析的版本:35ce778,Demo 地址:Volley Demo分析者:grumoon ...
- iOS 启动画面 代码自定义
先来看一个可能会遇到的问题: 如果你已经删除了xcode为你的项目自动生成的LaunchScreen.storyboard, 然后你在测试你的app的时候发现,屏幕里出现了黑色的区域,如上图(画红线的 ...
- jQuery Live Query 插件
http://www.cnblogs.com/sunjing/archive/2008/12/06/1349097.html 上篇日志里写到的那个问题其实有种更简单的解决办法,就是使用jquery的L ...
- js 爱恨情仇说 this
this 相信大家在写代码的时候都会遇到,可是怎么样才能用好this,估计这个还是有点困难的,虽然你有时候你会用到,但是他所在的具体的几个场景中所代表的是什么意思了?可能这个你就不是很清楚啊.这个就会 ...
- iOS常用技术
1.判断系统 #define UMSYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(v) ([[[UIDevice currentDevice] systemVersi ...
- 初玩Linux部署项目
1,先安装虚拟机2,安装centOS3,安装mysql 安装mysql客户端: yum install mysql 安装mysql 服务器端: yum install mysql-server yum ...
- linux系统中批量查找文件与文件内容的方法
在linux中查看与修改文件权限我们都必须使用命令来操作,不能像windows一样点几下就好了,下面我们简单的介绍一下linux中的相关命令 比如查找当前目录下面所有的php文件里面某个关键字 fin ...
- mac优秀软件介绍
1.首先是office软件: Microsoft_Office_2016_Installer.pkg 然后是一个破解软件 FWMSO2016VLU2.0.dmg_.zip 两个都不可少 2.然后是如果 ...
- SQl中的char,varcher,nvarchar,txt
CHAR char是定长的,在字段建立时,空间就固定了,不管是否插入值(NULL也包含在内),都占用字符的空间.例如: char(8),输入字符小于8,后面补空值.输入字符大于8时,会截取.CH ...
- VS2013菜单栏文字全大写的问题
从VS2010转到VS2013,2013新增的很多功能确实很方便,只是有一点,菜单栏文字变成全大写了,看着有点不习惯. 打开注册表编辑器,找到 HKEY_CURRENT_USER\Software\M ...