zoukankan      html  css  js  c++  java
  • HDU 2080 夹角有多大II

    http://acm.hdu.edu.cn/showproblem.php?pid=2080

    Problem Description
    这次xhd面临的问题是这样的:在一个平面内有两个点,求两个点分别和原点的连线的夹角的大小。

    注:夹角的范围[0,180],两个点不会在圆心出现。
     
    Input
    输入数据的第一行是一个数据T,表示有T组数据。
    每组数据有四个实数x1,y1,x2,y2分别表示两个点的坐标,这些实数的范围是[-10000,10000]。
     
    Output
    对于每组输入数据,输出夹角的大小精确到小数点后两位。
     
    Sample Input
    2
    1 1 2 2
    1 1 1 0
     
    Sample Output
    0.00
    45.00

    代码:

    #include <bits/stdc++.h>
    using namespace std;
    
    #define pi  3.14159265
    
    int main() {
        int T;
        while(~scanf("%d", &T)) {
            for(int i =1 ; i <= T; i ++) {
                double x1, y1, x2, y2;
                scanf("%lf%lf%lf%lf", &x1, &y1, &x2, &y2);
                double l1, l2, l3, ans;
                l1 = sqrt(x1 * x1 + y1 * y1);
                l2 = sqrt(x2 * x2 + y2 * y2);
                l3 = sqrt((y2 - y1) * (y2 - y1) + (x2 - x1) * (x2 - x1));
                ans = acos((l1 * l1+ l2 * l2 - l3 * l3) / ( 2 * l1 * l2)) * 180 / pi;
                printf("%0.2lf
    ", ans);
            }
        }
        return 0;
    }
    

      

  • 相关阅读:
    vim编辑器
    linux常用的命令解释
    克隆虚拟机及本地仓库的搭建
    创建windows系统下的虚拟机
    创建linux系统下的虚拟机
    drf频率组件
    django中过滤 搜索 排序
    drf分页
    js回顾
    数据类型
  • 原文地址:https://www.cnblogs.com/zlrrrr/p/9388621.html
Copyright © 2011-2022 走看看