1. 程式人生 > >hdu2076夾角有多大(題目已修改,注意讀題)解題報告---熱身

hdu2076夾角有多大(題目已修改,注意讀題)解題報告---熱身

                           夾角有多大(題目已修改,注意讀題)

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;
}