522人阅读 评论(0)

Clock

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

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$T$(1T104)$(1\leq T \leq 10^4)$ test cases
for each case,one line include the time

0hh<24$0 \leq hh \lt 24$,
0mm<60$0\leq mm\lt 60$,0ss<60$0\leq ss\lt60$

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

Author
SXYZ

Source

My Code$My \ Code：$

/**
2016 - 08 - 31 下午
Author: ITAK

Motto:

**/

#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <queue>
#include <algorithm>
#include <set>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
const int INF = 1e9+5;
const int MAXN = 1e6+5;
const int MOD = 1e9+7;
const double eps = 1e-7;
const double PI = acos(-1);
using namespace std;
LL Scan_LL()///输入外挂
{
LL res=0,ch,flag=0;
if((ch=getchar())=='-')
flag=1;
else if(ch>='0'&&ch<='9')
res=ch-'0';
while((ch=getchar())>='0'&&ch<='9')
res=res*10+ch-'0';
return flag?-res:res;
}
int Scan_Int()///输入外挂
{
int res=0,ch,flag=0;
if((ch=getchar())=='-')
flag=1;
else if(ch>='0'&&ch<='9')
res=ch-'0';
while((ch=getchar())>='0'&&ch<='9')
res=res*10+ch-'0';
return flag?-res:res;
}
void Out(LL a)///输出外挂
{
if(a>9)
Out(a/10);
putchar(a%10+'0');
}
inline int GCD(int a, int b)
{
if(b == 0)
return a;
return GCD(b, a%b);
}
int main()
{
int T, h, m, s, all = 360*120;
cin>>T;
while(T--)
{
scanf("%d:%d:%d",&h,&m,&s);
if(h >= 12)
h -= 12;
h = h*3600 + m*60 + s;
m = m*60 + s;
s = s*6;
m = m*12;
s = s*120;
int hm = abs(h-m);
int hs = abs(h-s);
int ms = abs(m-s);
hm = min(all-hm, hm);
hs = min(all-hs, hs);
ms = min(all-ms, ms);
int hm1 = GCD(hm, 120);
int hs1 = GCD(hs, 120);
int ms1 = GCD(ms, 120);
if(hm1 != 120)
printf("%d/%d ",hm/hm1,120/hm1);
else
printf("%d ",hm/hm1);
if(hs1 != 120)
printf("%d/%d ",hs/hs1,120/hs1);
else
printf("%d ",hs/hs1);
if(ms1 != 120)
printf("%d/%d \n",ms/ms1,120/ms1);
else
printf("%d \n",ms/ms1);
}
return 0;
}

0
0

个人资料
• 访问：528708次
• 积分：11547
• 等级：
• 排名：第1588名
• 原创：639篇
• 转载：5篇
• 译文：0篇
• 评论：93条
博客专栏
 计算机专业的相关课程知识 文章：24篇 阅读：32874
 ACM_组合数学 文章：27篇 阅读：32596
 ITAK的ACM之路 文章：295篇 阅读：342224
阅读排行
喜欢的Music
友情推荐