• <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>

            gzwzm06

              C++博客 :: 首頁 :: 新隨筆 :: 聯(lián)系 :: 聚合  :: 管理 ::
              1 隨筆 :: 52 文章 :: 17 評論 :: 0 Trackbacks
              1#include <cstdio>
              2#include <cmath>
              3
              4const int SIZE = 102;
              5
              6struct TPoint
              7{
              8    double x ;
              9    double y ;
             10}
             ;
             11
             12TPoint point[SIZE];
             13int N;
             14
             15double Distance( const TPoint& p1, const TPoint& p2 )
             16{
             17    return sqrt((p1.x - p2.x) * (p1.x - p2.x) + (p1.y - p2.y) * (p1.y - p2.y)) ;
             18}

             19
             20double GetALLDist( const TPoint& p, const int& n )
             21{
             22    int i;
             23    double sum = 0.0;
             24
             25    for ( i = 0; i < n; ++i )
             26        sum += Distance( p, point[i] );
             27
             28    return sum;
             29}

             30
             31double GetFermatPoint( const int& n )
             32{
             33    TPoint st = point[0];
             34    TPoint tmp, nt;
             35    double t, step = 100, fermat = GetALLDist(st, n);
             36
             37    while ( step > 0.2 )
             38    {
             39        int ok = 1;
             40
             41        while ( ok ) {
             42            ok = 0;
             43            nt = st;
             44
             45            tmp.x = st.x, tmp.y = st.y + step;
             46
             47            t = GetALLDist(tmp, n);
             48
             49            if ( t < fermat )
             50            {
             51                fermat = t;
             52                ok = 1;
             53                nt = tmp;
             54            }

             55
             56            tmp.x = st.x, tmp.y = st.y - step;
             57
             58            t = GetALLDist(tmp, n);
             59            if ( t < fermat )
             60            {
             61                fermat = t;
             62                ok = 1;
             63                nt = tmp;
             64            }

             65
             66            tmp.x = st.x + step, tmp.y = st.y;
             67
             68            t = GetALLDist(tmp, n);
             69
             70            if ( t < fermat )
             71            {
             72                fermat = t;
             73                ok = 1;
             74                nt = tmp;
             75            }

             76
             77            tmp.x = st.x - step, tmp.y = st.y;
             78
             79            t = GetALLDist(tmp, n);
             80            if ( t < fermat )
             81            {
             82                fermat = t;
             83                ok = 1;
             84                nt = tmp;
             85            }

             86            
             87            st = nt;
             88        }

             89
             90        step /= 2.0;
             91    }

             92
             93    return fermat;
             94}

             95
             96int main()
             97{
             98    int i, ans;
             99    double t;
            100
            101    scanf("%d"&N);
            102
            103    for ( i = 0; i < N; ++i )
            104    {
            105        scanf("%lf %lf"&point[i].x, &point[i].y);
            106    }

            107
            108    t = GetFermatPoint( N );
            109
            110    ans = (int)(t + 0.5* 100 / 100;
            111
            112    printf("%d\n", ans);
            113
            114    return 0;
            115}
            posted on 2009-03-31 12:08 閱讀(297) 評論(0)  編輯 收藏 引用 所屬分類: 幾何

            只有注冊用戶登錄后才能發(fā)表評論。
            網(wǎng)站導(dǎo)航: 博客園   IT新聞   BlogJava   博問   Chat2DB   管理


            www性久久久com| 久久国产香蕉一区精品| 国产精品久久久天天影视| 日本免费久久久久久久网站| 日韩电影久久久被窝网| 久久精品无码午夜福利理论片| 26uuu久久五月天| 伊人久久大香线蕉综合热线| 久久ZYZ资源站无码中文动漫 | 久久99久久成人免费播放| 亚洲乱码日产精品a级毛片久久| 熟妇人妻久久中文字幕| 久久综合视频网站| 久久香蕉国产线看观看99| 伊人久久综合精品无码AV专区 | 亚洲精品无码久久久久去q| 国产精品视频久久久| 欧美亚洲国产精品久久高清| 97超级碰碰碰碰久久久久| 欧美丰满熟妇BBB久久久| 久久久一本精品99久久精品88| 久久被窝电影亚洲爽爽爽| 久久精品人人做人人爽97| 久久笫一福利免费导航 | 狠狠色丁香婷婷久久综合 | 伊人久久大香线蕉综合Av| 亚洲一区精品伊人久久伊人| 久久99国产一区二区三区| 久久婷婷国产麻豆91天堂| 久久精品成人免费看| 国产日产久久高清欧美一区| 久久亚洲AV成人出白浆无码国产| 久久九九久精品国产免费直播| 亚洲国产精品成人久久蜜臀 | 日韩人妻无码一区二区三区久久 | 中文字幕无码av激情不卡久久| 久久久精品久久久久久| 久久天天躁狠狠躁夜夜2020| 亚洲欧洲精品成人久久曰影片| 香蕉久久影院| 色偷偷偷久久伊人大杳蕉|