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 ...
随机推荐
- DataTable转成Json
/// <summary> /// DataTable转成Json /// </summary> /// <param name=&quo ...
- zzulioj--1801--xue姐的小动物(水题)
1801: xue姐的小动物 Time Limit: 1 Sec Memory Limit: 128 MB Submit: 594 Solved: 168 SubmitStatusWeb Boar ...
- Codeforces--602A--Two Bases(水)
Two Bases Time Limit: 1000MS Memory Limit: 262144KB 64bit IO Format: %I64d & %I64u Submit St ...
- C#中如何获得两个日期之间的天数差 ( c# 计算两个日期之间相差的天数 )
DateTime dtLast = new DateTime(Convert.ToInt32(LastMenses.Year), Convert.ToInt32(LastMenses.Month), ...
- Web 端 js 导出csv文件
http://www.qdfuns.com/notes/35821/2ab249182734d1f5c66da6b5cf395db9.html
- css3 scale的用法例子
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...
- rowcount和@@rowcount的区别
1 rowcount rowcount的作用就是用来限定后面的sql在返回指定的行数之后便停止处理,比如下面的示例, set rowcount 10select * from 表A 这样的查询只会返回 ...
- Java基础算法
i++;++i; i--;--i; int a=5;int b=a++;++放在后面,表示先使用a的值,a再加1b=5,a=a+1,a=6 int c=5;int d=++c;++放在前面,表示先将c ...
- javaScript学习之正则表达式初探
正则表达式 正则表达式,又称规则表达式.(英语:Regular Expression,在代码中常简写为regex.regexp或RE),计算机科学的一个概念.正则表达式通常被用来检索.替换那些符 ...
- stat---显示文件的状态信息
stat命令用于显示文件的状态信息.stat命令的输出信息比ls命令的输出信息要更详细. 语法 stat(选项)(参数) 选项 -L:支持符号连接: -f:显示文件系统状态而非文件状态: -t:以简洁 ...