CDOJ Clock

Clock
Time Limit: 3000/1000MS (Java/Others) Memory Limit: 65535/65535KB (Java/Others)

Submit Status
Clock is invented by ancient Arabic engineers and which contributes to build the concept of accurate time for us human beings and even could be essential tool that widely used in industry, business and our routine lives. Nevertheless, the ideology of clock turns out to be quite simply that even make sense to little kids. We could hardly imagine that how do Arabic wisdom come up with such idea to indicate time only by two or three fingers. The other day, hhb are asking lxh and Hysramp to play his newly invented game describe as follow. hhb randomly change the time of his lovely alarm clock then ask lxh and Hysramp to tell the degree between hour finger and minute finger. lxh seems quite gifted playing it while Hysramp does not. When Hysramp fails to answer hhb, hhb smiles to Hysramp. And Hysramp smiles to you, an ace programmer.

Input
The first line of the input contains one integer T, which indicate the number of test cases. Each test case contains one indicating the time on hhb’s clock in the form of HH:MM. (0≤HH<24,0≤MM<60)

Output
One line for each test case contains only one number indicating the answer. An integer or an irreducible fraction indicated the degree between hour finger and minute finger.

Sample input and output
Sample Input Sample Output
1
00:00
0
Source
电子科技大学第七届ACM程序设计大赛 初赛

http://www.acm.uestc.edu.cn/#/problem/show/49

#include<stdio.h>
int main()
{
    int t,p, hh,mm, sh,sm,  res;
    scanf("%d",&t);
    for (p=1;p<=t;p++)
    {
        scanf("%d:%d",&hh,&mm);
        if (hh>=12)
            hh=hh-12;
        sh=hh*60+mm;
        sm=mm*12;
        if (sh>sm) res=sh-sm;
        else res=sm-sh;
        if (res>=360) res=720-res;
        if (res%2==0) printf("%d\n",res/2);
        else printf("%d/2\n",res);
    }
    return 0;
}
#include <iostream>
#include <sstream>
#include <iomanip>
#include <vector>
#include <deque>
#include <list>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <bitset>
#include <string>
#include <numeric>
#include <algorithm>
#include <functional>
#include <iterator>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <complex>
#include <ctime>

typedef long long LL;

const double pi = acos(-1.0);
const long long mod = 1e9 + 7;

using namespace std;

int main()
{
    //freopen("int.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    int T, H, M, ans;
    scanf("%d",&T);
    while(T--)
    {
        scanf("%d:%d",&H,&M);
        if(H >= 12)
            H = H - 12;
         ans = abs( 60 * H - 11 * M );
        if(ans >= 360)
            ans = 720 - ans;
        if(ans % 2 == 0)
            printf("%d\n",ans / 2);
        else
            printf("%d/2\n",ans);
    }
    return 0;
}

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值