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

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>
            先锋影音一区二区三区| 久久成年人视频| 亚洲麻豆av| 欧美日韩综合一区| 亚洲免费影院| 欧美一区激情| 亚洲成人在线| 亚洲激情国产| 欧美日韩妖精视频| 亚洲欧美中文另类| 羞羞视频在线观看欧美| 亚洲一区二区精品视频| 欧美日韩在线影院| 欧美一区二区三区在线| 欧美一区二区视频在线观看2020| 国产日韩欧美电影在线观看| 免费观看在线综合色| 欧美www视频在线观看| 一本大道久久a久久精二百| 亚洲一区二区精品视频| 一区在线电影| 亚洲免费高清视频| 激情久久综艺| 在线视频一区观看| 亚洲福利视频免费观看| 亚洲一区二区成人在线观看| 午夜精品久久久久久久| 亚洲免费观看在线观看| 亚洲欧美另类中文字幕| 亚洲人成人一区二区三区| 99在线热播精品免费| 伊人久久婷婷色综合98网| 亚洲欧洲日本国产| 国产综合色精品一区二区三区| 亚洲第一黄色网| 国产欧美亚洲视频| 亚洲精品一区二区三区在线观看 | av不卡在线| 狠狠狠色丁香婷婷综合激情| 亚洲精品小视频在线观看| 韩曰欧美视频免费观看| 99热免费精品| 亚洲人成在线播放| 欧美在线免费看| 欧美一区二区免费| 欧美午夜片欧美片在线观看| 欧美成人精品在线播放| 国产免费一区二区三区香蕉精| 亚洲国产精品va在线观看黑人| 国产免费成人av| 一区二区欧美日韩| 99re6这里只有精品视频在线观看| 久久精品欧美| 欧美制服丝袜| 国产精品一区在线观看| 一区二区不卡在线视频 午夜欧美不卡在 | 欧美日韩三级电影在线| 欧美成人一区在线| 尤物yw午夜国产精品视频| 小黄鸭精品aⅴ导航网站入口| 亚洲永久免费视频| 欧美日韩在线视频一区| 亚洲美女视频在线免费观看| 91久久精品日日躁夜夜躁欧美| 欧美在线一区二区三区| 久久久99精品免费观看不卡| 国产精品高清网站| 久久精品人人做人人综合| 国产精品美女在线观看| 一区二区三区四区国产精品| 亚洲影院色在线观看免费| 欧美日韩在线精品| 一本久道久久综合狠狠爱| 亚洲视频免费| 国产精品人人做人人爽| 亚洲一区二区三区精品在线观看| 亚洲专区在线视频| 国产日韩欧美一区二区三区四区| 亚洲午夜久久久| 久久黄色影院| 亚洲国产精品成人综合色在线婷婷| 久久女同精品一区二区| 亚洲国产综合在线| 中文久久乱码一区二区| 国产精品色网| 久久另类ts人妖一区二区| 欧美激情亚洲精品| 一区二区欧美视频| 国产九区一区在线| 鲁鲁狠狠狠7777一区二区| 亚洲激情在线| 亚洲欧美制服另类日韩| 国内综合精品午夜久久资源| 久久日韩粉嫩一区二区三区| 亚洲国产成人tv| 欧美中在线观看| 亚洲精品久久久久| 国产精品影院在线观看| 久久亚洲精品一区二区| 亚洲人成亚洲人成在线观看| 性做久久久久久久久| 亚洲第一精品夜夜躁人人爽| 国产精品av免费在线观看| 久久成人一区| 在线中文字幕一区| 免费观看欧美在线视频的网站| 在线视频欧美日韩精品| 好吊日精品视频| 国产精品久久久久天堂| 免费日韩av电影| 欧美一级午夜免费电影| 亚洲精品一品区二品区三品区| 久久久国产一区二区| 日韩亚洲一区二区| 一区在线影院| 国产精品一区久久久久| 欧美成人午夜激情视频| 久久精品官网| 亚洲永久免费视频| 日韩视频精品在线| 亚洲国产精品电影| 久久婷婷麻豆| 欧美资源在线观看| 亚洲女人天堂成人av在线| 亚洲精品欧美精品| 亚洲黄色性网站| 国内久久精品| 国产欧美一区二区三区在线老狼 | 久久久999| 亚洲综合精品| 中文在线不卡| 亚洲麻豆视频| 最新精品在线| 欧美黑人国产人伦爽爽爽| 久久手机精品视频| 久久久久国色av免费看影院| 欧美一区二区啪啪| 欧美一区二区播放| 欧美一区二区三区免费在线看 | 在线不卡免费欧美| 国产一区香蕉久久| 国产在线拍偷自揄拍精品| 国产精品成av人在线视午夜片| 欧美精品18+| 欧美日韩精品一区视频| 欧美精品videossex性护士| 欧美成人综合网站| 欧美国产日韩精品免费观看| 欧美国产日韩一区| 欧美日韩aaaaa| 欧美手机在线| 国产伦理一区| 狠狠色狠狠色综合日日小说| 国产一区二区三区最好精华液| 国产亚洲综合精品| 在线观看视频一区二区| 亚洲人成免费| 亚洲在线播放电影| 欧美中文在线免费| 欧美成人午夜激情在线| 亚洲国产三级在线| 亚洲视频免费| 久久aⅴ国产紧身牛仔裤| 久久婷婷亚洲| 欧美三级午夜理伦三级中视频| 国产精品高潮呻吟久久av无限| 国产精品一区二区久久精品| 国产一区二区三区久久 | 免费中文日韩| 91久久精品日日躁夜夜躁国产| 亚洲裸体在线观看| 亚洲欧美久久久久一区二区三区| 欧美一级视频精品观看| 久久一区二区三区四区五区| 欧美另类videos死尸| 国产精品美女久久久免费| 国模 一区 二区 三区| 亚洲国产日韩欧美综合久久| 中文欧美字幕免费| 理论片一区二区在线| 亚洲另类视频| 性欧美办公室18xxxxhd| 欧美激情第3页| 国产香蕉久久精品综合网| 亚洲三级网站| 久久激情视频| 妖精成人www高清在线观看| 欧美在线观看网站| 欧美视频一区| 亚洲黄色一区二区三区| 欧美中文字幕视频| 亚洲狼人综合| 美女视频一区免费观看| 国产日韩欧美三区| 亚洲天堂第二页| 欧美激情导航| 欧美在线亚洲| 国产精品日韩一区| 在线综合+亚洲+欧美中文字幕| 蜜臀99久久精品久久久久久软件|