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(1≤T≤104) test
cases

for each case,one line include the time



0≤hh<24,0≤mm<60,0≤ss<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
这是一道简单模拟。但我做了挺长时间,果然模拟题还是非常弱啊。。这里注意尽量不要涉及小数,由于会影响精度。
#include<iostream>
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<string>
#include<algorithm>
using namespace std;
int c[10][4],e,f;
int gcd(int a, int b){ return a == 0 ? b : gcd(b % a, a); }
void jian(int a,int b,int c,int d){
int i,j,t1,t2,t;
t1=a*d-b*c;
t2=b*d;
t=gcd(t2,t1);
e=t1/t;
f=t2/t;
} int main()
{
int h,m,t,s,n,i,j,T,x2,y2,x3,y3;
char c1,c2;
double b1,b2,b3;
scanf("%d",&T);
while(T--)
{
scanf("%d:%d:%d",&h,&m,&s);
if(h>=12)h-=12;
t=h*3600+m*60+s;
c[1][1]=t;
c[1][2]=120; c[2][1]=m*60+s;
c[2][2]=10; c[3][1]=s*6;
c[3][2]=1; e=f=0;
jian(c[1][1],c[1][2],c[2][1],c[2][2]);
if(e*f>0){
e=f=0;
jian(c[1][1],c[1][2],c[2][1],c[2][2]);
if(e>f*180)jian(360,1,e,f);
if(f==1)printf("%d ",e);
else printf("%d/%d ",e,f);
}
else{
e=f=0;
jian(c[2][1],c[2][2],c[1][1],c[1][2]);
if(e>f*180)jian(360,1,e,f);
if(f==1)printf("%d ",e);
else printf("%d/%d ",e,f);
} e=f=0;
jian(c[1][1],c[1][2],c[3][1],c[3][2]);
if(e*f>0){
e=f=0;
jian(c[1][1],c[1][2],c[3][1],c[3][2]);
if(e>f*180)jian(360,1,e,f);
if(f==1)printf("%d ",e);
else printf("%d/%d ",e,f);
}
else{
e=f=0;
jian(c[3][1],c[3][2],c[1][1],c[1][2]);
if(e>f*180)jian(360,1,e,f);
if(f==1)printf("%d ",e);
else printf("%d/%d ",e,f);
} e=f=0;
jian(c[2][1],c[2][2],c[3][1],c[3][2]);
if(e*f>0){
e=f=0;
jian(c[2][1],c[2][2],c[3][1],c[3][2]);
if(e>f*180)jian(360,1,e,f);
if(f==1)printf("%d ",e);
else printf("%d/%d ",e,f);
}
else{
e=f=0;
jian(c[3][1],c[3][2],c[2][1],c[2][2]);
if(e>f*180)jian(360,1,e,f);
if(f==1)printf("%d ",e);
else printf("%d/%d ",e,f);
}
printf("\n");
}
return 0;
}

最新文章

  1. CentOS / Redhat : Configure CentOS as a Software Router with two interfaces
  2. Atititcmd cli环境变量的调用设置与使用
  3. CF# Educational Codeforces Round 3 E. Minimum spanning tree for each edge
  4. VS2010 调试不会命中当前断点
  5. Xamarin.Android开发实践(十)
  6. BZOJ1722 [Usaco2006 Mar] Milk Team Select 产奶比赛
  7. Linux Mint下编译Bochs
  8. php连接到数据库
  9. 下拉刷新ListView实现原理
  10. Xamarin.Android 入门之:Xamarin+vs2015 环境搭建
  11. Hadoop之Flume 记录
  12. 原生js获取 一个dom元素距离页面可视区域的位置值 -- getBoundingClientRect
  13. document,element,node方法
  14. springboot 接收post和get请求
  15. linux下的wireshark最新版安装(源码安装)以及一些常见问题
  16. Macaca之Android原理浅析
  17. UVA - 11021 Tribles 概率dp
  18. Apache httpd服务部署
  19. Balls(poj 3783)
  20. 编写高质量代码改善C#程序的157个建议——建议86:Parallel中的异常处理

热门文章

  1. delete 用法总结
  2. python 发送邮件 &lt;QQ+腾讯企业邮箱&gt;
  3. spring在web.xml中的配置
  4. ArcGIS Engine 9.3启动程序报错
  5. windows 常见环境变量(%AppData%、%TEMP%、%TMP%)
  6. 移动端meta几个值的设置以及含义
  7. Kinect 开发 —— 手势识别(下)
  8. Oracle新建表字段,如何使字段自增
  9. ajax事件(五)
  10. command---调用指定的指令并执行