poj 1266 Cover an Arc.

时间:2022-06-19 11:09:09

http://poj.org/problem?id=1266

Cover an Arc.
Time Limit: 1000MS   Memory Limit: 10000K
Total Submissions: 823   Accepted: 308

Description

A huge dancing-hall was constructed for the Ural State University's 80-th anniversary celebration. The size of the hall is 2000 * 2000 metres! The floor was made of square mirror plates with side equal to 1 metre. Then the walls were painted with an indelible paint. Unfortunately, in the end the painter flapped the brush and the beautiful mirror floor was stained with the paint. But not everything is lost yet! The stains can be covered with a carpet. 
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

The input consists of six integers. At first the coordinates of the arc's ends are given. The co-ordinates of an inner point of the arc follow them. Absolute value of coordinates doesn't exceed 1000. The points don't belong the same straight line. The arc lies inside the square [-1000,1000] * [-1000,1000].

Output

You should write to the standard output the minimal square of the carpet covering this arc.

Sample Input

476 612
487 615
478 616

Sample Output

66

Source

 
 
 
分析:
几何题, 求正方形覆盖圆弧的面积。
 
 
 
AC代码:
 #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.的更多相关文章

  1. Ural 1043 Cover the Arc

    题目链接:http://acm.timus.ru/problem.aspx?space=1&num=1043 题目大意:一个2000*2000方格坐标,x,y范围都是[-1000,1000]. ...

  2. POJ - 1266 -

    题目大意:给出一条圆弧上的两个端点A,B,和圆弧上两端点之间的一个点C,现在要用一块各个定点的坐标均为整数的矩形去覆盖这个圆弧,要求最小的矩形面积. 思路:叉积在本体发挥很强大的作用.首先求出三个点所 ...

  3. poj 2376 Cleaning Shifts

    http://poj.org/problem?id=2376 Cleaning Shifts Time Limit: 1000MS   Memory Limit: 65536K Total Submi ...

  4. POJ 2528 Mayor&&num;39&semi;s posters

    Mayor's posters Time Limit:1000MS     Memory Limit:65536KB     64bit IO Format:%I64d & %I64u Sub ...

  5. 【POJ 2482】Stars in Your Window

    http://poj.org/problem?id=2482 线段树扫描线 #include<cstdio> #include<cstring> #include<alg ...

  6. POJ 2446 最小点覆盖

    Chessboard Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 14787   Accepted: 4607 Descr ...

  7. poj 2446 Chessboard &lpar;二分匹配&rpar;

    Chessboard Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 12800   Accepted: 4000 Descr ...

  8. POJ 2528 Mayor&&num;39&semi;s posters(线段树区间染色&plus;离散化或倒序更新)

    Mayor's posters Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 59239   Accepted: 17157 ...

  9. Poj&lpar;2784&rpar;,二进制枚举最小生成树

    题目链接:http://poj.org/problem?id=2784 Buy or Build Time Limit: 2000MS   Memory Limit: 65536K Total Sub ...

随机推荐

  1. 【Java EE 学习 36】【struts2】【struts2系统验证】【struts2 ognl值栈】【struts2 ongl标签】【struts2 UI标签】【struts2模型驱动和令牌机制】

    一.struts2系统验证 1.基于struts2系统验证的方式实际上就是通过配置xml文件的方式达到验证的目的. 2.实际上系统校验的方法和手工校验的方法在底层的基本实现是相同的.但是使用系统校验的 ...

  2. git的两本推荐书

    1. pro git, 可以网页直接看 http://iissnan.com/progit/?spm=5176.100239.blogcont5843.18.nUJDcK 2. Git权威指南 &lt ...

  3. Android 布局 中实现适应屏幕大小及组件滚动

    要实现如图的布局: 这是在eclipse可视化窗口中的截图,但实际运行在Android设备上可能出现的问题有: (1):当编辑图1中的最后一个EditText时,输入法的编辑界面会把底部的Button ...

  4. &period;Net HttpClient 模拟登录微信公众平台发送消息

    1.模拟登录 public WeiXinRetInfo ExecLogin(string name, string pass) { CookieContainer cc = new CookieCon ...

  5. Python3基础 nonlocal关键字 内部函数访问到外部函数的变量

    镇场诗: 诚听如来语,顿舍世间名与利.愿做地藏徒,广演是经阎浮提. 愿尽吾所学,成就一良心博客.愿诸后来人,重现智慧清净体.-------------------------------------- ...

  6. &lbrack;安全&rsqb;PHP能引起安全的函数

    php中需要禁用以下函数来提高安全性 打开php.ini  找到 disable_functions .然后禁用以下函数 [C] 纯文本查看 复制代码 ? 1 disable_functions = ...

  7. Git——如何将本地项目提交至远程仓库&lpar;第一次&rpar;

    1.(先进入项目文件夹)通过命令 git init 把这个目录变成git可以管理的仓库. git init 2.把文件添加到版本库中,使用命令 git add .添加到暂存区里面去,不要忘记后面的小数 ...

  8. CustomScrollView &plus; slivers &plus; SliverAppBar

    import 'package:flutter/material.dart'; void main()=>runApp(MyApp()); class MyApp extends Statele ...

  9. Android BLE蓝牙详细解读

    代码地址如下:http://www.demodashi.com/demo/15062.html 随着物联网时代的到来,越来越多的智能硬件设备开始流行起来,比如智能手环.心率检测仪.以及各式各样的智能家 ...

  10. unity2d开发windows phone游戏按钮问题

    今天在进行unity2d项目对windows phone工程的编译过程中,发现了一个很蛋疼的bug,windows phone编译运行后,GUILayout.Button出现自动点击的现象,这带来了很 ...