• poj 1266 Cover an Arc.


    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代码:
     1 #include<iostream>
     2 #include<algorithm>
     3 #include<stdio.h>
     4 #define max(a,b) a>b?a:b
     5 #define min(a,b) a>b?b:a
     6 #include<math.h>
     7 using namespace std;
     8 #define eps 1e-8
     9 struct point{double x,y;};
    10 struct line {point a,b;};
    11 point a,b,c;
    12 double xmult(point p1,point p2,point p0){
    13  return (p1.x-p0.x)*(p2.y-p0.y)-(p2.x-p0.x)*(p1.y-p0.y);
    14 }
    15 bool pp(point p)
    16 {
    17     double t1,t2;
    18     t1=(xmult(a,c,b));
    19     t2=(xmult(a,p,b));
    20     if ((t1<0&&t2<0)||(t1>0&&t2>0)) return true;
    21     return false;
    22 }
    23 double distan (point p1,point p2)
    24 {
    25     return sqrt((p1.x-p2.x)*(p1.x-p2.x)+(p1.y-p2.y)*(p1.y-p2.y));
    26 }
    27 point inter(line u,line v)
    28 {
    29     point ret = u.a;
    30     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));
    31     ret.x +=(u.b.x-u.a.x)*t;
    32     ret.y +=(u.b.y-u.a.y)*t;
    33     return ret;
    34 }
    35 point circle(point a,point b,point c )
    36 {
    37     line u,v;
    38     u.a.x =(a.x+b.x)/2;
    39     u.a.y = (a.y+b.y)/2;
    40     u.b.x = u.a.x - a.y+b.y;
    41     u.b.y = u.a.y + a.x-b.x;
    42     v.a.x = (a.x+c.x)/2;
    43     v.a.y = (a.y+c.y)/2;
    44     v.b.x = v.a.x - a.y+c.y;
    45     v.b.y = v.a.y+a.x-c.x;
    46     return inter(u,v);
    47 }
    48 int main()
    49 {
    50     point d,e,p;
    51     int cas =1;
    52     while(~scanf("%lf %lf %lf %lf %lf %lf",&a.x,&a.y,&b.x,&b.y,&c.x,&c.y))
    53     {
    54         d = circle(a,b,c);
    55         double bj = distan(d,a);
    56         double maxx,maxy,minx,miny;
    57         double dd=d.x,yy=d.y;
    58         int ax,bx,cx,ay,by,cy;
    59         maxx=max(a.x,b.x);
    60         maxx=max(maxx,c.x);
    61         minx=min(a.x,b.x);
    62         minx=min(minx,c.x);
    63         maxy=max(a.y,b.y);
    64         maxy=max(maxy,c.y);
    65         miny=min(a.y,b.y);
    66         miny=min(miny,c.y);
    67         p.x=d.x-bj;
    68         p.y=d.y;
    69         if(pp(p))
    70             minx=p.x;
    71         p.x=d.x+bj;
    72         if(pp(p))
    73             maxx=p.x;
    74         p.x=d.x;
    75         p.y=d.y-bj;
    76         if(pp(p))
    77             miny=p.y;
    78         p.y=d.y+bj;
    79         if(pp(p))
    80             maxy=p.y;
    81         cx=(long)ceil(maxx-eps)-(long)floor(minx+eps);
    82         cy=(long)ceil(maxy-eps)-(long)floor(miny+eps);
    83         printf("%d
    ",cx*cy);
    84     }
    85     return 0;
    86 }
  • 相关阅读:
    JS调用WebService
    C# FTP FtpWebRequest UsePassive 属性
    vs2010 rdlc .net4.0 卸载 Appdomain 时出错。 (异常来自 HRESULT:0x80131015) 解决办法
    DotNetBar RibbonControl控件office2007风格
    C# WinForm RDLC报表不预览直接连续打印
    C# 调用 WebService 连接ORACLE 11g
    C# WinForm程序打印条码 Code39码1
    RDLC报表 在WinForm里运行出现 未能加载文件或程序集microsoft.reportviewer.winforms
    C# 使用 SAP NCO3.0 调用SAP RFC函数接口
    在ui自动化中,如果有多个case在不同的class 下,要全部执行并且要求只启动一次浏览器页面,怎么处理?
  • 原文地址:https://www.cnblogs.com/jeff-wgc/p/4483824.html
Copyright © 2020-2023  润新知