zoukankan      html  css  js  c++  java
  • 夹角有多大(题目已修改,注意读题)

    夹角有多大(题目已修改,注意读题)

    Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
    Total Submission(s): 15858    Accepted Submission(s): 6291


    Problem Description
    时间过的好快,一个学期就这么的过去了,xhd在傻傻的看着表,出于对数据的渴望,突然他想知道这个表的时针和分针的夹角是多少。现在xhd知道的只有时间,请你帮他算出这个夹角。

    注:夹角的范围[0,180],时针和分针的转动是连续而不是离散的。
     
    Input
    输入数据的第一行是一个数据T,表示有T组数据。
    每组数据有三个整数h(0 <= h < 24),m(0 <= m < 60),s(0 <= s < 60)分别表示时、分、秒。
     
    Output
    对于每组输入数据,输出夹角的大小的整数部分。
     
    Sample Input
    2
    8 3 17
    5 13 30
     
    Sample Output
    138
    75
     
    Author
    xhd
     
    Source
     
    Recommend
    lcy   |   We have carefully selected several similar problems for you:  2078 2079 2080 2075 2077 
    用个floor,只保留整数部分就好,其余用double存数据
    #include<iostream>
    #include<cstdio>
    #include<queue>
    #include<vector>
    #include<cmath>
    #include<cstring>
    using namespace std;
    #define maxn 1010
    int f(int n)
    {
        if(n==2)
            return 1;
        for(int i=2; i<=sqrt(n); i++)
        {
            if(n%i==0)
                return 0;
        }
        return 1;
    }
    int main()
    {
        int h,m,s;
        int t;
        while(~scanf("%d",&t))
        {
            while(t--)
            {
                scanf("%d%d%d",&h,&m,&s);
                if(h>=12)
                    h = h - 12;//判断是否大于12
                double num1,num2;
                num1 = h*30.0 + m * 0.5 + (s*1.0*0.5)/60;
                num2 = m*6.0 + s*0.1;
                double num = num1-num2;
                if(fabs(num)>180)
                    printf("%.0lf
    ",floor(360-fabs(num)));
                else printf("%.0lf
    ",floor(fabs(num)));
            }
        }
        return 0;
    }
    彼时当年少,莫负好时光。
  • 相关阅读:
    网站首页蒙灰CSS样式
    MATLAB数值计算编程题
    通过P/Invoke控制继电器
    Java实习生入职测试
    navicat for mongodb12破解
    用svg绘制圣诞帽
    Excel条件格式
    10道算法题
    从事软件开发工作10年后的总结
    ASP.NET Core MVC+EF Core从开发到部署
  • 原文地址:https://www.cnblogs.com/l609929321/p/6606329.html
Copyright © 2011-2022 走看看