http://hihocoder.com/problemset/problem/1562
时间限制:
10000ms
单点时限:
1000ms
内存限制:
256MB
描述
小Hi喜欢各种角度。一天,他注意到了钟表上的角度,于是他想考考他的好朋友小Ho:对于一个24小时制的时刻,在 t 秒之后,对应在钟表上时针与分针的夹角是多少。为保证答案的唯一性,只需考虑不超过180°的角。你能帮助小Ho解决这个问题吗?
例如,下图可表示15点30分0秒经过0秒后的时间,其对应的夹角为75°和285°,在这个问题中我们只考虑不超过180°的角,所以此时的夹角为75°。
输入
输入包含多组测试数据。
第一行为测试数据的组数T(1 ≤ T ≤ 1000)
对于每组数据:
第一行包含三个整数h,m,s,表示给定时刻的时、分、秒(0 ≤ h ≤ 23,0 ≤ m ≤ 59,0 ≤ s ≤ 59)
第二行包含一个整数t,表示经过的秒数(0 ≤ t ≤ 1000000000)
输出
对于每组数据,输出时针与分针的夹角。四舍五⼊保留小数点后四位。
3 15 30 0 0 14 30 0 3600 15 30 0 3600样例输出
75.0000 75.0000 45.0000
#include<iostream>
#include<cstring>
#include<string>
#include<iomanip>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<map>
#include<set>
#include<algorithm>
using namespace std;
typedef long long ll;
int main()
{
int h,m,s,t,T,hh,mm,ss;
double res;
scanf("%d",&T);
while(T--)
{
scanf("%d%d%d%d",&h,&m,&s,&t);
s=s+t;
hh=s/3600;
s=s-hh*3600;
h=h+hh;
h=h%12;
mm=s/60;
s=s-mm*60;
m=m+mm;
if(m>=60)
{
m%=60;
h=(h+1)%12;
}
res=fabs(-30*h*1.0+5.5*m*1.0+0.1*s*1.0-1*1.0/120*s);
if(res>180)
res=360*1.0-res;
cout<<fixed<<setprecision(4)<<res<<endl;
}
}