zoukankan      html  css  js  c++  java
  • lightoj-1433

    1433 - Minimum Arc Distance
    PDF (English) Statistics Forum
    Time Limit: 2 second(s) Memory Limit: 32 MB
    You all probably know how to calculate the distance between two points in two dimensional cartesian plane. But in this problem you have to find the minimum arc distance between two points and they are on a circle centered at another point.

    You will be given the co-ordinates of the points A and B and co-ordinate of the center O. You just have to calculate the minimum arc distance between A and B. In the picture, you have to calculate the length of arc ACB. You can assume that A and B will always be on the circle centered at O.

    Input
    Input starts with an integer T (≤ 100), denoting the number of test cases.

    Each case starts with a line containing six integers Ox, Oy, Ax, Ay, Bx, By where (Ox, Oy) indicates the co-ordinate of O, (Ax, Ay) denote the co-ordinate of A and (Bx, By) denote the co-ordinate of B. All the integers will lie in the range [1, 10000].

    Output
    For each case, print the case number and the minimum arc distance. Errors less than 10-3 will be ignored.

    Sample Input
    Output for Sample Input
    5
    5711 3044 477 2186 3257 7746
    3233 31 3336 1489 1775 134
    453 4480 1137 6678 2395 5716
    8757 2995 4807 8660 2294 5429
    4439 4272 1366 8741 6820 9145
    Case 1: 6641.81699183
    Case 2: 2295.92880
    Case 3: 1616.690325
    Case 4: 4155.64159340
    Case 5: 5732.01250253

    #include<iostream>
    #include<cstdio>
    #include<cmath>
    #include<algorithm>
    using namespace std;
    const double pi = 3.1415926535898;
    double dist(double x1,double y1,double x2,double y2){
        return sqrt(pow(x1-x2,2)+pow(y1-y2,2));
    }
    
    int main(){
        
        int T;
        double ox,oy,ax,ay,bx,by,a,b,c,arc;
        
        scanf("%d",&T);
        for(int t=1;t<=T;t++){
            
            scanf("%lf%lf%lf%lf%lf%lf",&ox,&oy,&ax,&ay,&bx,&by);
            
            a = dist(ox,oy,ax,ay);
            c = dist(ax,ay,bx,by);
            arc = acos((a*a*2-c*c)/(2*a*a));
            printf("Case %d: %.3lf
    ",t,a*arc);
            
        }
        
        return 0;
    } 
  • 相关阅读:
    【scala】定义变量和函数
    【python】self用法详解
    【Hive】自定义函数
    【Java】抽象类和接口
    Linux中的wheel用户组是什么?
    CentOS6.9切换root用户su root输入正确密码后一直提示Incorrect password,如何解决?
    CentOS7.X中使用yum安装nginx的方法
    Win10提示“因为文件共享不安全,所以你不能连接到文件共享”如何处理
    vim编辑器-多行加注释与去注释
    CentOS7.4用yum安装并配置MySQL5.7
  • 原文地址:https://www.cnblogs.com/yuanshixingdan/p/5563800.html
Copyright © 2011-2022 走看看