HDU 多校 VIII 1008 clock

Clock

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 377    Accepted Submission(s): 200


Problem Description
Give a time.(hh:mm:ss),you should answer the angle between any two of the minute.hour.second hand
Notice that the answer must be not more 180 and not less than 0
 

Input
There are  T (1T104)  test cases
for each case,one line include the time

0hh<24 , 0mm<60 , 0ss<60
 

Output
for each case,output there real number like A/B.(A and B are coprime).if it's an integer then just print it.describe the angle between hour and minute,hour and second hand,minute and second hand.
 

Sample Input
  
  
4 00:00:00 06:00:00 12:54:55 04:40:00
 

Sample Output
  
  
0 0 0 180 180 0 1391/24 1379/24 1/2 100 140 120
Hint
每行输出数据末尾均应带有空格

/*
 * In the name of god (^_^)
 */
#pragma comment(linker, "/STACK:1024000000,1024000000")
#include<cstdio>
#include<cmath>
#include<stdlib.h>
#include<map>
#include<set>
#include<time.h>
#include<vector>
#include<queue>
#include<string>
#include<string.h>
#include<iostream>
#include<algorithm>
using namespace std;
#define eps 1e-8
#define PI acos(-1.0)
#define INF 0x3f3f3f3f
#define LL long long
#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))
typedef pair<int , int> pii;
int h, m, s;
int t[4];
int ans[3];
int gcd(int a, int b)
{
    return b == 0 ? a : gcd(b, a % b);
}
int main()
{
    int T;
    scanf("%d", &T);
    while(T--)
    {
        scanf("%d:%d:%d", &h, &m, &s);
        t[3] = s * 720;
        t[2] = m * 720 + s * 12;
        t[1] = (h % 12) * 3600 + m * 60 + s;
        ans[0] = abs(t[1] - t[2]);
        ans[1] = abs(t[1] - t[3]);
        ans[2] = abs(t[2] - t[3]);
        for(int i = 0; i < 3; i++)
        {
            if(ans[i] > 180 * 120) ans[i] = 360 * 120 - ans[i];
            if(ans[i]%120 == 0)
                printf("%d ", ans[i]/120);
            else
            {
                int tmp = gcd(ans[i], 120);
                printf("%d/%d ", ans[i]/tmp, 120/tmp);
            }
        }
        printf("\n");
    }
    return 0;
}
/*
4
00:00:00
06:00:00
12:54:55
04:40:00
*/


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值