题意:给出一个时间,求在石英钟上显示这个时间,时针和分针之间的角度,并对角度进行取整
链接:http://acm.hdu.edu.cn/showproblem.php?pid=2076
思路:全部转化成秒,用过秒的比例转化成角度,在进行计算
注意点:所求夹角可能超过180度
以下为AC代码:
Run ID | Submit Time | Judge Status | Pro.ID | Exe.Time | Exe.Memory | Code Len. | Language | Author |
12683839 | 2015-01-11 23:57:00 | Accepted | 2076 | 15MS | 1252K | 1256 B | G++ | luminous11 |
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <vector>
#include <deque>
#include <list>
#include <cctype>
#include <algorithm>
#include <climits>
#include <queue>
#include <stack>
#include <cmath>
#include <map>
#include <set>
#include <iomanip>
#include <cstdlib>
#include <ctime>
#define ll long long
#define ull unsigned long long
#define all(x) (x).begin(), (x).end()
#define clr(a, v) memset( a , v , sizeof(a) )
#define pb push_back
#define mp make_pair
#define read(f) freopen(f, "r", stdin)
#define write(f) freopen(f, "w", stdout)
using namespace std;
const double pi = acos(-1);
int main()
{
ios::sync_with_stdio( false );
int n;
cin >> n;
while (n -- ){
int a, b, c;
cin >> a >> b >> c;
if ( a > 12 ) a -= 12;
double ang_1 = ( b * 60.0 + c ) / 10.0;
double ang_2 = ( a * 3600.0 + b * 60.0 + c ) / ( 10.0 * 12.0 );
double ans = 0;
if ( ang_1 > ang_2 ){
ans = ang_1 - ang_2;
}
else{
ans = ang_2 - ang_1;
}
if ( ans > 180 ) ans = 360.0 - ans;
cout << fixed << setprecision (0) << ans - 0.5 << endl;
}
return 0;
}