青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品

oyjpArt ACM/ICPC算法程序設(shè)計空間

// I am new in programming, welcome to my blog
I am oyjpart(alpc12, 四城)
posts - 224, comments - 694, trackbacks - 0, articles - 6

PKU2504 Rounding Box

Posted on 2008-05-04 14:41 oyjpart 閱讀(2725) 評論(3)  編輯 收藏 引用 所屬分類: ACM/ICPC或其他比賽
前幾天的練習(xí)賽有一道計算幾何題,一向討厭計算幾何的我推了一下之后就沒做了。
后來比賽結(jié)束的時候發(fā)現(xiàn)他們都過了,后悔不已。故做了一下,求三角形外接圓圓心那個我使用
垂直平分線相交的那個做的。上次他們說有公式,我在書上找了個圓心公式,可是代進(jìn)去不對。
估計是書上公式寫錯了...
 Bounding box
Time Limit: 1.0 Seconds   Memory Limit: 65536K
Total Runs: 28   Accepted Runs: 14    Multiple test files



The Archeologists of the Current Millenium (ACM) now and then discover ancient artifacts located at vertices of regular polygons. The moving sand dunes of the desert render the excavations difficult and thus once three vertices of a polygon are discovered there is a need to cover the entire polygon with protective fabric.

Input contains multiple cases. Each case describes one polygon. It starts with an integer n ≤ 50, the number of vertices in the polygon, followed by three pairs of real numbers giving the x and y coordinates of three vertices of the polygon. The numbers are separated by whitespace. The input ends with a n equal 0, this case should not be processed.

For each line of input, output one line in the format shown below, giving the smallest area of a rectangle which can cover all the vertices of the polygon and whose sides are parallel to the x and y axes.

Sample input

4
10.00000 0.00000
0.00000 -10.00000
-10.00000 0.00000
6
22.23086 0.42320
-4.87328 11.92822
1.76914 27.57680
23
156.71567 -13.63236
139.03195 -22.04236
137.96925 -11.70517
0

Output for the sample input

Polygon 1: 400.000
Polygon 2: 1056.172
Polygon 3: 397.673

// solution by alpc12
#include <cstdio>
#include <cmath>

const double EPS = 1e-8;
const double PI = acos(-1.0);
const double INF = 1e100;

#define Min(a, b) (a<b?a:b)
#define Max(a, b) (a>b?a:b)

struct Point {
    double x;
    double y;
    Point() {}
    Point(double xx, double yy) {
        x = xx;
        y = yy;
    }
};

struct Line {
    double a, b, c;
    Point st, end;
    Line() {}
    Line(Point& u, Point& v) {
        st = u;
        end = v;
        a = v.y - u.y;
        b = u.x - v.x;
        c = a*u.x + b*u.y;
    }
};

#define sqr(a) ((a)*(a))
#define dist(a, b) (sqrt( sqr((a).x-(b).x)+sqr((a).y-(b).y) ))
#define cross(a, b, c)  (((b).x-(a).x)*((c).y-(a).y)-((b).y-(a).y)*((c).x-(a).x))

inline int dblcmp(double a, double b = 0.0) {
    if(fabs(a-b) < EPS) return 0;
    return a < b ? -1 : 1;
}

Line bisector(Point& a, Point& b) {
    Line line(a, b), ans;    
    double midx = (a.x+b.x)/2, midy = (a.y+b.y)/2;
    ans.a = -line.b, ans.b = line.a, ans.c = ans.a*midx + ans.b*midy;
    return ans;
}

int line_line_intersect(Line& l1, Line& l2, Point& s) {
    double det = l1.a * l2.b - l2.a * l1.b;
    if(dblcmp(det) == 0) {
        return -1;
    }
    s.x = (l2.b*l1.c - l1.b*l2.c) / det;
    s.y = (l1.a*l2.c - l2.a*l1.c) / det;
    return 1;
}

int center_3point(Point& a, Point& b, Point& c, Point& s, double& r) {
    Line x = bisector(a, b), y = bisector(b, c);
    if(line_line_intersect(x, y, s) == 1) {
        r = dist(s, a);
        return 1;
    }
    return 0;
}

Point p[55];

int main() {

    //freopen("t.in", "r", stdin);

    int i, n, tc = 0;
    Point cent;
    while(scanf("%d", &n), n) {
        for(i = 0; i < 3; ++i) scanf("%lf %lf ", &p[i].x, &p[i].y);
        double r;
        if(center_3point(p[0], p[1], p[2], cent, r) == 1) {
            for(i = 0; i < 3; ++i)
                p[i].x -= cent.x, p[i].y -= cent.y;
        }
        double alpha = acos(p[0].x / r);
        double theta = 2 * PI / n;
        double xmin = INF, xmax = -INF, ymin = INF, ymax = -INF;
        for(i = 0; i < n; ++i) {
            p[i] = Point(r * cos(alpha + i * theta),
                r * sin(alpha + i * theta));
            xmin = Min(xmin, p[i].x);
            xmax = Max(xmax, p[i].x);
            ymin = Min(ymin, p[i].y);
            ymax = Max(ymax, p[i].y);
        }
        printf("Polygon %d: %.3lf\n", ++tc, (xmax-xmin)*(ymax-ymin));
    }
    return 0;
}

Feedback

# re: PKU2504 Rounding Box  回復(fù)  更多評論   

2008-05-05 09:02 by oyjpart
那個大牛給我個正確的求圓心的坐標(biāo)的公式?

# re: PKU2504 Rounding Box  回復(fù)  更多評論   

2008-05-05 12:21 by alpc55
@oyjpart
想要嗎~~~
我有哈~~~

# re: PKU2504 Rounding Box  回復(fù)  更多評論   

2008-05-05 14:35 by oyjpart
謝謝啊
青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品
  • <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>
            亚洲一级片在线看| 国产亚洲综合在线| 在线亚洲美日韩| 欧美怡红院视频| 韩国久久久久| 欧美大片免费久久精品三p | 国产精品进线69影院| 亚洲中无吗在线| 看片网站欧美日韩| 亚洲国产欧美在线| 国产精品日韩精品| 免费在线日韩av| 黄色成人在线网址| 欧美涩涩网站| 久久综合亚洲社区| 亚洲自拍三区| 亚洲国产精品久久久久秋霞影院 | 99亚洲一区二区| 欧美a级片一区| 久久久久99| 亚洲欧美日韩国产综合精品二区| **网站欧美大片在线观看| 国产精品国码视频| 欧美激情精品久久久久久变态| 午夜精品国产精品大乳美女| 亚洲国产一二三| 欧美成年人视频| 免费日韩视频| 久久亚洲欧洲| 久久久亚洲国产天美传媒修理工| 亚洲久久视频| 中国亚洲黄色| av不卡在线观看| 亚洲精品一区二区在线观看| 亚洲丰满在线| 洋洋av久久久久久久一区| 亚洲欧洲日产国码二区| 亚洲另类视频| 亚洲午夜久久久| 亚洲欧美一区二区在线观看| 亚洲午夜视频在线观看| 亚洲欧美日韩成人| 亚洲欧美日韩专区| 久久久午夜电影| 欧美福利在线观看| 日韩视频在线观看国产| 亚洲视频在线视频| 久久久久一区二区| 欧美精品xxxxbbbb| 国产色婷婷国产综合在线理论片a| 国产视频久久| av成人福利| 久久先锋影音| 日韩视频在线一区二区三区| 欧美一区二区三区在| 欧美精品一区二| 亚洲欧美网站| 亚洲影音一区| 欧美日本高清一区| 影音先锋日韩资源| 亚洲永久免费av| 91久久在线视频| 久久久久久婷| 国产亚洲免费的视频看| 一区二区三区 在线观看视| 久久综合九色综合欧美狠狠| 一区二区三区**美女毛片| 久久综合导航| 亚洲国产99精品国自产| 久久久久久久91| 欧美在线国产精品| 国产女精品视频网站免费| 亚洲一级片在线看| 亚洲日本理论电影| 免费人成精品欧美精品| 亚洲国产一区二区三区a毛片| 亚洲天堂成人| 亚洲一区成人| 国产日韩欧美中文| 久久精品一二三| 久久经典综合| 亚洲精品在线视频| 欧美国产三区| 欧美日韩一区二区三区在线看| 中日韩高清电影网| 亚洲在线一区| 136国产福利精品导航网址| 免费亚洲一区| 欧美性片在线观看| 久久久久久国产精品mv| 欧美成人午夜激情视频| 亚洲视频在线二区| 久久精品国产亚洲一区二区| 亚洲福利免费| 亚洲专区在线视频| 亚洲电影成人| 亚洲欧美激情视频在线观看一区二区三区 | 欧美一区二区三区久久精品茉莉花| 国产日产欧美a一级在线| 欧美国产视频在线| 国产精品一区2区| 亚洲精品国产精品久久清纯直播| 国产精品久久影院| 亚洲黄色成人网| 国产一区二区高清| 亚洲在线观看| 亚洲免费视频中文字幕| 99热在线精品观看| 欧美精彩视频一区二区三区| 亚洲桃色在线一区| 欧美精品成人| 亚洲黄色成人久久久| 国产日韩欧美在线播放不卡| 在线一区二区三区四区| 日韩一本二本av| 欧美日韩中文字幕精品| 亚洲三级影院| 夜夜嗨av一区二区三区四季av| 免费看亚洲片| 欧美高清在线一区二区| 亚洲激情成人在线| 欧美成人伊人久久综合网| 久久久久五月天| 激情一区二区| 欧美精品在线一区二区| 亚洲精品久久久久久久久久久久久| 亚洲片区在线| 国产精品乱码| 久久成人人人人精品欧| 免费成人高清在线视频| 亚洲美女黄网| 国产精品久久久久久久久久免费看| 亚洲一区欧美| 欧美激情91| 亚洲欧美精品suv| 在线播放日韩专区| 欧美日韩一二三区| 久久精品人人做人人爽电影蜜月| 欧美不卡一区| 销魂美女一区二区三区视频在线| 国产一区二区三区久久 | 伊人夜夜躁av伊人久久| 欧美视频网站| 欧美成人激情视频免费观看| 亚洲午夜一区| 亚洲精品黄色| 乱人伦精品视频在线观看| 亚洲制服av| 亚洲午夜免费视频| 亚洲电影第1页| 在线观看精品| 国内揄拍国内精品久久| 国产欧美日韩在线播放| 国产精品白丝av嫩草影院| 蜜桃av一区二区三区| 欧美在线视频一区二区| 亚洲一区二区在线观看视频| 一本色道久久综合亚洲精品婷婷| 欧美a一区二区| 免费成人av在线看| 欧美高清你懂得| 亚洲激情成人| 99精品国产在热久久下载| 最新日韩中文字幕| 亚洲免费播放| 性欧美xxxx视频在线观看| 亚洲午夜精品| 亚洲人成啪啪网站| 99精品欧美一区二区三区综合在线 | 黄色日韩精品| 伊人色综合久久天天五月婷| 亚洲高清在线播放| 一区二区欧美精品| 亚洲综合色在线| 久久在线免费| 亚洲精品网站在线播放gif| 亚洲视频导航| 久久久久.com| 国产精品久久久一区麻豆最新章节| 国产精品拍天天在线| 在线日本高清免费不卡| 99re这里只有精品6| 久久久久久91香蕉国产| 亚洲精品一二| 久久―日本道色综合久久| 欧美日韩在线观看一区二区三区| 国产精品午夜电影| 亚洲作爱视频| 蜜桃av综合| 欧美亚洲网站| 国产欧美日韩在线观看| 日韩天堂在线视频| 欧美福利在线| 久久深夜福利| 国产主播一区二区三区四区| 亚洲在线视频| 一区二区毛片| 欧美日韩精品一区二区三区四区| 在线免费观看一区二区三区| 欧美一区二区三区日韩视频|