hdu2076夹角有多大(题目已修改,注意读题)解题报告---热身

版权声明:转载请注明出处:https://blog.csdn.net/qq1013459920 https://blog.csdn.net/qq1013459920/article/details/84144176

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

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

 

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

思路:(时针角度-分钟角度)res > 180 ? 360 - res:res

AC Code:

#include<iostream>
#include<sstream>
#include<cstdlib>
#include<cmath>
#include<cctype>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<list>
#define mod 998244353
#define INF 0x3f3f3f3f
#define Min 0xc0c0c0c0
#define mst(a) memset(a,0,sizeof(a))
#define f(i,a,b) for(int i=a;i<b;i++)
using namespace std;
typedef long long ll;
const int maxn = 1e6 + 5;
const double pi = acos(-1);
int main(){
    int T;
    scanf("%d", &T);
    while(T--){
        int h, m, s;
        scanf("%d%d%d", &h, &m, &s);
        h = h % 12;
        double res = fabs((h + (double)m / 60.0 + (double)s / 3600.0) * 30 - ((double)m + (double)s / 60) * 6);
        if(res > 180) res = 360 - res;
        printf("%d\n", (int)res);
    }
    return 0;
}

猜你喜欢

转载自blog.csdn.net/qq1013459920/article/details/84144176
今日推荐