hdu5387 Clock
Notice that the answer must be not more 180 and not less than 0
cases
for each case,one line include the time
0≤hh<24,0≤mm<60,0≤ss<60
4
00:00:00
06:00:00
12:54:55
04:40:00
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;
}
hdu5387 Clock的更多相关文章
- [hdu5387 Clock]时钟夹角问题
题意:给一个时刻,求时针.分钟.秒针三者之间的夹角 思路:确定参照点,求出三者的绝对夹角,然后用差来得到它们之间的夹角,钝角情况用360.减去就行了. #include <map> #in ...
- hdu5387(2015多校8)--Clock(模拟)
题目链接:点击打开链接 题目大意:给出一个时间,问在钟表上这个时间的时候.时针和分针的角度,时针和秒针的角度.分针和秒针的角度.假设不是整数以分数的形式输出. 假设依照最小的格来算,那么: 1s对于秒 ...
- 修改Linux系统日期与时间date clock
先设置日期 date -s 20080103 再设置时间 date -s 18:24:30 为了永久生效,需要将修改的时间写入CMOS. 查看CMOS的时间: #clock -r 将当前系统时间写到C ...
- 操作系统页面置换算法(opt,lru,fifo,clock)实现
选择调出页面的算法就称为页面置换算法.好的页面置换算法应有较低的页面更换频率,也就是说,应将以后不会再访问或者以后较长时间内不会再访问的页面先调出. 常见的置换算法有以下四种(以下来自操作系统课本). ...
- Cesium应用篇:3控件(1)Clock
创建 跟Clock相关的主要有Animation控件和Timeline控件,通常两者会放在一起使用. 在Cesium中,Viewer默认开启这两个控件,如果你想要不显示控件,可以在Viewer初始化中 ...
- get back to the slower clock rate that allows it to save more power
http://www.howtogeek.com/177790/why-you-cant-use-cpu-clock-speed-to-compare-computer-performance/ Wh ...
- Clock rate
https://en.wikipedia.org/wiki/Clock_rate The clock rate typically refers to the frequency at which a ...
- clock()、time()、clock_gettime()和gettimeofday()函数的用法和区别【转】
转自:http://www.cnblogs.com/krythur/archive/2013/02/25/2932647.html 转自http://blog.sina.com.cn/s/blog_7 ...
- 最少clock
var elClock = document.getElementById("clock");var getTime = function(){ var _ = ['00','01 ...
随机推荐
- Entity Framework介绍和DBFirst开发方式
一.ORM概念 什么是ORM? 对象关系映射(英语:(Object Relational Mapping,简称ORM,或O/RM,或O/R mapping),是一种程序技术.简单来说,就是将关系型数 ...
- POJ 1293 网络流 第一题
完全的模板,做多了就好了吧 反向流量真的很有意思,有这样一种说法比较容易理解.”正向是+,反向就是-,其实是等价的.因为每次找到的增广路不一定是最优解里面的,所以再进行后面的操作的时候要重新选择,而反 ...
- Zuul 2 : The Netflix Journey to Asynchronous, Non-Blocking Systems--转
原文地址:http://techblog.netflix.com/2016/09/zuul-2-netflix-journey-to-asynchronous.html We recently mad ...
- Design Pattern - Service Locator Pattern--转载
原文地址:http://www.tutorialspoint.com/design_pattern/service_locator_pattern.htm The service locator de ...
- Installation from source on Windows 7 with Visual C++2012
在这部分说明里,你将会学习到在配备有Visual C++的Windows平台下从源码安装ViSP.下面的这些安装步骤已经在32位Windows系统,CMake3.1和Visual Studio 201 ...
- 昼猫笔记 JavaScript -- 作用域技巧!!
简单理解 var zm = function (x) { var code = 'bb' return code }; 学过js的老哥们都知道,当这样简单的一个函数进入浏览器,浏览器开始解释代码,会将 ...
- 休假结束,Linus重回内核开发岗位
在休假反省一个多月之后,Linus Torvalds 又回来了.10 月 22 日爱丁堡举行的欧洲开源峰会上,Linus Torvalds 将与内核维护者们碰头,这是他重新接管Linux内核开发的第一 ...
- blkid---对系统块设备信息查询
在Linux下可以使用blkid命令对查询设备上所采用文件系统类型进行查询.blkid主要用来对系统的块设备(包括交换分区)所使用的文件系统类型.LABEL.UUID等信息进行查询.要使用这个命令必须 ...
- sed的一些tricks
1.sed -f xx.sed input_file 可以将一系列操作放在一个xx.sed脚本里执行 ``` #!/bin/sed -f ``` 2.在匹配字符串后面或行尾添加内容 在text后面添加 ...
- JAVA多态学习1
多态–概念 所谓多态.就是指一个引用(类型)在不同情况下的多种状态. 也能够理解成:多态是指通过指向父类的指针,来调用在不同子类中实现的方法. 实现多态有两种方式:1.继承.2.接口 这一次我们先来演 ...