HDOJ 5387 Clock 水+模拟
2024-09-08 14:25:52
Clock
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 316 Accepted Submission(s): 215
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
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 120Hint每行输出数据末尾均应带有空格
Source
/* ***********************************************
Author :CKboss
Created Time :2015年08月13日 星期四 22时23分29秒
File Name :HDOJ5387.cpp
************************************************ */ #include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <queue>
#include <set>
#include <map> using namespace std; int hh,mm,ss; int alltime(int h,int m,int s)
{
return h*3600+m*60+s;
} const int mod=360*120; int main()
{
//freopen("in.txt","r",stdin);
//freopen("out.txt","w",stdout); int T_T;
scanf("%d",&T_T);
while(T_T--)
{
scanf("%d:%d:%d",&hh,&mm,&ss); int at=alltime(hh,mm,ss);
int hhdu=at%mod;
int mmdu=12*at%mod;
int ssdu=720*at%mod; int dur_hm=abs(mmdu-hhdu);
if(dur_hm>mod/2) dur_hm=mod-dur_hm; int dur_hs=abs(hhdu-ssdu);
if(dur_hs>mod/2) dur_hs=mod-dur_hs; int dur_ms=abs(mmdu-ssdu);
if(dur_ms>mod/2) dur_ms=mod-dur_ms; int g1=__gcd(dur_hm,120);
int g2=__gcd(dur_hs,120);
int g3=__gcd(dur_ms,120); ///print dur_hm
if(g1==120) printf("%d ",dur_hm/g1);
else printf("%d/%d ",dur_hm/g1,120/g1); ///print dur_hs
if(g2==120) printf("%d ",dur_hs/g2);
else printf("%d/%d ",dur_hs/g2,120/g2); ///print dur_hs
if(g3==120) printf("%d \n",dur_ms/g3);
else printf("%d/%d \n",dur_ms/g3,120/g3);
} return 0;
}
最新文章
- ROW_NUMBER over (order by **)
- Android实现与PHP服务器的交互
- 时间同步出现ntpdate[1788]: the NTP socket is in use, exiting
- OpenJudge计算概论-错误探测
- C#多态;父类引用指向子类对象;new和override的区别;new、abstract、virtual、override,sealed关键字区别和使用代码示例;c#类的初始化顺序
- android-support-xxxx.jar NoClassDefFoundError
- 移动web:转盘抽奖(幸运大转盘)
- VxWorks 基本启动方式
- protel dxp 2004安装与破解
- 实现鼠标悬停,div勾画div边框的动画
- leetcode 381.Insert Delete GetRandom
- C/C++ 多线程机制
- vhdl——type
- PHP函数可变参数
- Extending a logical volume in a virtual machine running Red Hat or Cent OS (1006371)
- 理解JavaWeb项目中的路径问题——相对路径与绝对路径
- WinFrom饼形图
- 使用JMAP dump及分析dump文件
- ComicEnhancerPro 系列教程十七:二值化图像去毛刺
- Windos Server Tomcat 双开配置