hdu5387 Clock
来源:互联网 发布:易语言和java 编辑:程序博客网 时间:2024/06/05 00:30
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
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
for each case,one line include the time
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
400:00:0006:00:0012:54:5504: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;}
0 0
- hdu5387 Clock
- hdu5387 Clock
- HDU5387 Clock 时钟模拟
- hdu5387 Clock(数学水题)
- hdu5387 六校 Clock(水题 模拟)
- hdu5387(2015多校8)--Clock(模拟)
- HDU5387
- hdu5387 Clock(分数加减法模拟及分数化简)
- [水题] hdu5387 多校联合第八场 Clock
- hdu5387(模拟)
- hdu5387 模拟时钟
- clock
- clock
- clock
- Clock
- CLOCK
- clock
- Clock
- Linux中fork()函数知识详解
- java实现最小长方形, 判断一个数字中是否包含两个相同的子串, 取石子游戏.
- 内核通知链原理及机制
- Havok_2014-1-0_Pc_Xs_User_Guide(1.5.7-计时器)
- HDU 4265(Science!-二分网络流)
- hdu5387 Clock
- 键盘输入问题:输入错误左移一位,求原来输入的串
- Http的连接方式之HttpUrlConnection
- HDOJ 2048 神、上帝以及老天爷(错排公式)
- Bibtex 如何cite 不同格式
- leetcode 122: Best Time to Buy and Sell Stock II
- 高仿知乎日报(二)
- 零基础学python-2.18 异常
- coj 1214: 三个数字