[HDU] [2076] How Big Is the Angle

Problem Description

Loading...

Problem Analysis

A contest really does change everything about a person
The problem statement already gives the hint
The rotation is continuous, not discrete
So you need double to record the fractional parts

cpp
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
#include<stdio.h>
#include<math.h>
int main() {
	int T;
	scanf("%d",&T);
	while(T--) {
		int h,m,s;
		scanf("%d %d %d",&h,&m,&s);
		h%=12;
		double tm=s/10.0+m*6.0;
		double th=h*30.0+tm/12.0;
		double res=fabs(th-tm);
		if(res>360-res)
			res=360-res;
		printf("%d\n",(int)res);
	}
	return 0;
}

Problem link:HDU 2076 How Big Is the Angle

This post is licensed under CC BY-NC-SA 4.0. If it helped, or if you have anything to say, the comment box below is open.
Page views —
Unique visitors —

Loading...