hdu 2076 夹角有多大(题目已修改,注意读题)
夹角有多大(题目已修改,注意读题)
Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Problem Description
时间过的好快,一个学期就这么的过去了,xhd在傻傻的看着表,出于对数据的渴望,突然他想知道这个表的时针和分针的夹角是多少。现在xhd知道的只有时间,请你帮他算出这个夹角。
注:夹角的范围[0,180],时针和分针的转动是连续而不是离散的。
注:夹角的范围[0,180],时针和分针的转动是连续而不是离散的。
Input
输入数据的第一行是一个数据T,表示有T组数据。
每组数据有三个整数h(0 <= h < 24),m(0 <= m < 60),s(0 <= s < 60)分别表示时、分、秒。
每组数据有三个整数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
#include<iostream> #include<algorithm> #include<stdio.h> #include<string.h> #include<math.h> using namespace std; int main() {//时针12小时转过360°, //所以每一小时时针转过30°, //即60分钟转过30°,所以每一分钟转过0.5° //60s 0.5 一秒 0.5/60 //60m 360 1m=6; 60s=6 1s 0.1 int num,h,m,s; double a; cin>>num; while(num--) { cin>>h>>m>>s; if(h>=12) h-=12; a=fabs((h+m*1.0/60+s*1.0/3600)*30-(m+s*1.0/60)*6); if((int)a>180) cout<<(int)(360-a)<<endl; else if((int)a==180) cout<<0<<endl; else cout<<(int)a<<endl; } }