HDOJ 2076 夹角有多大(题目已修改,注意读题)

66 篇文章 0 订阅

题意:给出一个时间,求在石英钟上显示这个时间,时针和分针之间的角度,并对角度进行取整

链接:http://acm.hdu.edu.cn/showproblem.php?pid=2076

思路:全部转化成秒,用过秒的比例转化成角度,在进行计算

注意点:所求夹角可能超过180度


以下为AC代码:

Run IDSubmit TimeJudge StatusPro.IDExe.TimeExe.MemoryCode Len.LanguageAuthor
126838392015-01-11 23:57:00Accepted207615MS1252K1256 BG++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;
}


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值