• <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>
            隨筆 - 87  文章 - 279  trackbacks - 0
            <2025年8月>
            272829303112
            3456789
            10111213141516
            17181920212223
            24252627282930
            31123456

            潛心看書研究!

            常用鏈接

            留言簿(19)

            隨筆分類(81)

            文章分類(89)

            相冊

            ACM OJ

            My friends

            搜索

            •  

            積分與排名

            • 積分 - 219045
            • 排名 - 118

            最新評論

            閱讀排行榜

            評論排行榜

            Easy Problem

            Time limit:1000 ms   Memory limit:65536 KB
            Total Submit:1755 (462 users)   Accepted Submit:366 (332 users)

            Description

            In this problem, you're to calculate the distance between a point P(xp, yp, zp) and a segment (x1, y1, z1) − (x2, y2, z2), in a 3D space, i.e. the minimal distance from P to any point Q(xq, yq, zq) on the segment (a segment is part of a line).

            Input

            The first line contains a single integer T (1 ≤ T ≤ 1000), the number of test cases. Each test case is a single line containing 9 integers xp, yp, zp, x1, y1, z1, x2, y2, z2. These integers are all in [-1000,1000].

            Output

            For each test case, print the case number and the minimal distance, to two decimal places.

            Sample Input

            3
            0 0 0 0 1 0 1 1 0
            1 0 0 1 0 1 1 1 0
            -1 -1 -1 0 1 0 -1 0 -1

            Sample Output

            Case 1: 1.00
            Case 2: 0.71
            Case 3: 1.00

            Problem Source

            The 32nd ACM-ICPC Beijing First Round Internet Contest

            其實和二分差不多,劃個函數曲線出來,分三段,比劃一下就很容易理解了:)

            #include <iostream>
            #include 
            <cmath>
            using namespace std;

            double dist(double l[], double r[]) {
                
            return sqrt((l[0]-r[0])*(l[0]-r[0])+(l[1]-r[1])*(l[1]-r[1])+(l[2]-r[2])*(l[2]-r[2]));
            }


            int main() {
               
            // freopen("1024.in", "r", stdin);
                int n, cas=0;
                
            double l[3], r[3], p[3], p1[3], p2[3], d1, d2;
                scanf(
            "%d"&n);
                
            while (n--{
                    scanf(
            "%lf%lf%lf%lf%lf%lf%lf%lf%lf"&p[0], &p[1], &p[2], &l[0], &l[1], &l[2], &r[0], &r[1], &r[2]);
                    
            while (dist(l, r) > 1e-4{
                        p1[
            0= (l[0+ r[0]) / 2;
                        p1[
            1= (l[1+ r[1]) / 2;
                        p1[
            2= (l[2+ r[2]) / 2;
                        p2[
            0= (r[0+ p1[0]) / 2;
                        p2[
            1= (r[1+ p1[1]) / 2;
                        p2[
            2= (r[2+ p1[2]) / 2;
                        d1 
            = dist(p1, p); d2 = dist(p2, p);
                        
            if (d2 >= d1) {
                            r[
            0= p2[0]; r[1= p2[1]; r[2= p2[2];
                        }
             else {
                            l[
            0= p1[0]; l[1= p1[1]; l[2= p1[2];
                        }

                    }

                    printf(
            "Case %d: %.2lf\n"++cas, dist(p,l));
                }

            }

            posted on 2007-10-18 11:00 閱讀(1209) 評論(0)  編輯 收藏 引用 所屬分類: 算法&ACM
            免费精品久久天干天干| 99久久成人国产精品免费| 亚洲另类欧美综合久久图片区| 久久人妻少妇嫩草AV蜜桃| 久久中文字幕人妻熟av女| avtt天堂网久久精品| 性高湖久久久久久久久AAAAA| 久久久久成人精品无码中文字幕| 国产精品久久久久久福利69堂| 久久久久国产一级毛片高清板| 亚洲欧美伊人久久综合一区二区| AAA级久久久精品无码区| 午夜欧美精品久久久久久久| 久久精品国产清自在天天线| 久久精品无码专区免费青青 | 无码人妻久久一区二区三区免费丨| 伊人久久免费视频| 日韩久久久久久中文人妻| 久久综合亚洲色HEZYO国产| 91久久精品91久久性色| 久久精品卫校国产小美女| 久久一区二区三区免费| 97精品伊人久久久大香线蕉| 91久久精品91久久性色| 久久久国产精品亚洲一区| 97久久婷婷五月综合色d啪蜜芽| 久久精品国产亚洲av瑜伽| 久久久精品免费国产四虎| 欧洲人妻丰满av无码久久不卡| 中文精品99久久国产| 日韩AV毛片精品久久久| 精品久久久久国产免费| 91精品国产综合久久香蕉| 777久久精品一区二区三区无码| 国产精品久久自在自线观看| 久久人人爽爽爽人久久久| 日韩精品久久久肉伦网站| 久久精品国产亚洲AV无码娇色| 久久人人爽人人爽人人片av高请| 99久久人妻无码精品系列蜜桃| 久久精品国产亚洲AV高清热|