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 ...
随机推荐
- Wpf/Wp/Silverlight-Chart图表控件:柱状图、饼状图等使用汇总
链接:http://www.cnblogs.com/jimson/archive/2010/06/21/Wpfchat.html http://www.cnblogs.com/mgen/p/32361 ...
- Kinect的那些事儿
Kinect结合Unity3d跑酷游戏体感Demo 今天收拾东西,在柜子的翻出了一台崭新的Kinect,说起来真是惭愧,大学毕业那会儿,慈老师(和名字一位慈祥的好老师,也是我的毕业设计指导老师)赞 助 ...
- linux errno使用
errno详解 http://blog.csdn.net/wang_517766334/article/details/7561495 #include <errno.h> 就可以直接打印 ...
- Java的算数运算符、关系运算符、逻辑运算符、位运算符
JAVA的运算符,分为四类: 算数运算符.关系运算符.逻辑运算符.位运算符 算数运算符(9):+ - * / % ++ -- 关系运算符(6):== != > >= & ...
- 02.JavaScript基础下
运算符 算术:+ 加.- 减.* 乘./ 除.% 取模 实例:隔行变色.秒转时间 赋值:=.+=.-=.*=./=.%= 关系:<.>.<=.>=.==.===.!=(不等). ...
- 谢欣伦 - OpenDev原创教程 - 设备查找类CxDeviceFind & CxDeviceMapFind
这是一个精练的设备查找类,类名.函数名和变量名均采用匈牙利命名法.小写的x代表我的姓氏首字母(谢欣伦),个人习惯而已,如有雷同,纯属巧合. CxDeviceFind的使用如下: void CUsbSc ...
- Sublime Text 3 杂记
Sublime Text 是一个功能强大的代码编辑器(收费,但可无限期试用).由程序员Jon Skinner于2008年1月份所开发出来,它最初被设计为一个具有丰富扩展功能的Vim.Sublime T ...
- python2.x与3.x差别
数字常量: 八进制 十六进制 二进制 2:0177 0o177 0x9ff 0b101010 3:0o177 0x9ff 0b101010 多种字符串: 2:一般字符串,Unicode字符串 3: ...
- BZOJ 1003 物流运输【最短路】【动态规划】
这道题数据太小啦!先枚举i,j表示从第i天到第j天不更改航线的费用. 然后直接跑最短路算法(我用的是Q版男朋友算法) 动归方程显然是f[i] = min(f[i], f[j] + cost[j+1][ ...
- PHP和HTML代码混合编译的三种方法
第一种是在HTML中加PHP. 大段大段的html代码中,在各个需要执行php的地方<?php .... ?> 比如 line7-9: 1 <head> 2 <meta ...