题目传送门:点击传送
Time limit per test:1 second
Memory limit per test:256 megabytes
Description
Do you remember a kind cartoon "Beauty and the Beast"? No, no, there was no firing from machine guns or radiation mutants time-travels!
There was a beauty named Belle. Once she had violated the Beast's order and visited the West Wing. After that she was banished from the castle...
Everybody was upset. The beautiful Belle was upset, so was the Beast, so was Lumiere the candlestick. But the worst thing was that Cogsworth was upset. Cogsworth is not a human, but is the mantel clock, which was often used as an alarm clock.
Due to Cogsworth's frustration all the inhabitants of the castle were in trouble: now they could not determine when it was time to drink morning tea, and when it was time for an evening stroll.
Fortunately, deep in the basement are lying digital clock showing the time in the format HH:MM. Now the residents of the castle face a difficult task. They should turn Cogsworth's hour and minute mustache hands in such a way, that Cogsworth began to show the correct time. Moreover they need to find turn angles in degrees for each mustache hands. The initial time showed by Cogsworth is 12:00.
You can only rotate the hands forward, that is, as is shown in the picture:
As since there are many ways too select such angles because of full rotations, choose the smallest angles in the right (non-negative) direction.
Note that Cogsworth's hour and minute mustache hands move evenly and continuously. Hands are moving independently, so when turning one hand the other hand remains standing still.
Input
The only line of input contains current time according to the digital clock, formatted as HH:MM (00 ≤ HH ≤ 23, 00 ≤ MM ≤ 59). The mantel clock initially shows 12:00.
Pretests contain times of the beginning of some morning TV programs of the Channel One Russia.
Output
Print two numbers x and y — the angles of turning the hour and minute hands, respectively (0 ≤ x, y < 360). The absolute or relative error in the answer should not exceed 10 - 9.
输入输出样例
输入样例 | 输出样例 |
12:00 | 0 0 |
04:30 | 135 180 |
08:17 | 248.5 102 |
解析:
题面很长,读好题目你会发现....这...
对于每一个时间,输出这个时间时钟里的时针和分针分别需要逆时针旋转多少度才与12:00的重合。
由于时钟只有12小时,所以24小时的22:00与10:00是一样的。(大于等于12的减一个12就好了)
然后算一下每分钟时针和分针分别旋转角度,这题套下公式就完了....
每分钟时针旋转角度:360/12/60=0.5度
每分钟分针旋转角度:360/60=6度
所以x(x<12)小时y分钟角度
时针:x*30+y*0.5
分针:y*6
代码
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <queue>
int main()
{
int h,m;
double angh,angm;
scanf("%2d:%2d",&h,&m);
if(h>=12)
h-=12;
angm=6*m;//分针角度
angh=h*30+m*0.5;//时针角度
printf("%f %f\n",angh,angm);
return 0;
}