Atcoder abc 168 C
C - : (Colon)
Time Limit: 2 sec / Memory Limit: 1024 MB
Score: 300300 points
Problem Statement
Consider an analog clock whose hour and minute hands are AA and BB centimeters long, respectively.
An endpoint of the hour hand and an endpoint of the minute hand are fixed at the same point, around which each hand rotates clockwise at constant angular velocity. It takes the hour and minute hands 1212 hours and 11 hour to make one full rotation, respectively.
At 00 o'clock, the two hands overlap each other. HH hours and MM minutes later, what is the distance in centimeters between the unfixed endpoints of the hands?
Constraints
- All values in input are integers.
- 1≤A,B≤10001≤A,B≤1000
- 0≤H≤110≤H≤11
- 0≤M≤590≤M≤59
Input
Input is given from Standard Input in the following format:
AA BB HH MM
Output
Print the answer without units. Your output will be accepted when its absolute or relative error from the correct value is at most 10−910−9.
Sample Input 1 Copy
Copy
3 4 9 0
Sample Output 1 Copy
Copy
5.00000000000000000000
The two hands will be in the positions shown in the figure below, so the answer is 55 centimeters.
Sample Input 2 Copy
Copy
3 4 10 40
Sample Output 2 Copy
Copy
4.56425719433005567605
The two hands will be in the positions shown in the figure below. Note that each hand always rotates at constant angular velocity.
思路:余弦定理。
#include<iostream>
#include<cmath>
#define dou double
using namespace std;
const dou pie = acos(-1.0);
int main()
{
dou a,b,h,m;
cin>>a>>b>>h>>m;
double x = h * 60 + m;
x /= 720;
x *= 2 * pie;
double y = m / 60 * 2 * pie;
double z = abs(x - y);
dou ans = sqrt(a*a + b*b -2*a*b*cos(z));
printf("%.9lf",ans);
return 0;
}
推荐阅读
-
ABC108C - Triangular Relationship(打表)
-
AtCoder Beginner Contest 182----C. To 3
-
atcoder046C - AtCoDeer and Election Report
-
【考研每日一题7】abc(C++)
-
博思得C168点击打印后打印机不打印的排除故障
-
博思得C168怎么排除打印机跳纸的故障?
-
Atcoder abc 160 (A~E)
-
习题和dowhile 使用switch语句,要求输入1,输出abc;输入2输出bc,输入3输出C。
-
atcoder abc 159:F - Knapsack for All Segments(思维 + 贡献 + dp)
-
Atcoder - abc176 -- D - Wizard in Maze【BFS + 双端队列】