Clock


Time Limit: 2 Seconds      Memory Limit: 65536 KB

You are given a standard 12-hour clock with analog display, an hour hand and a minute hand. How many times does the minute hand pass the hour hand in a given time interval?

Sample Input

12 50  1  2
3 8 3 20
2 45 11 0
11 0 3 20
1 2 12 50
3 20 3 8

Sample Output

Program 3 by team X
Initial time Final time Passes
12:50 01:02 0
03:08 03:20 1
02:45 11:00 8
11:00 03:20 4
01:02 12:50 11
03:20 03:08 10
End of program 3 by team X

题目的下边还有一大段,当时出在HUST上,根本分不清哪输出格式是哪个,谁知道最前边最后边那句话也需要。当时有一次试了一下加上这两句,其他地方哪里又出错了。看了题解,直接把最后一次提交的错误代码, 加上这两句输出,直接A了,坑

判断分针和时针相遇的次数

代码如下:

 # include <iostream>
# include<cstdio>
# include<cstring>
using namespace std; int main()
{
int a,b,c,d,ans;
double tmp1,tmp2,tmp3,tmp4;
printf("Program 3 by team X\n");
printf("Initial time Final time Passes\n");
while(scanf("%d%d%d%d",&a,&b,&c,&d)!= EOF)
{
printf(" ");
printf("%02d:%02d",a,b);
printf(" ");
printf("%02d:%02d",c,d);
printf(" ");
if(a==)
a=;
if(c==)
c=;
tmp2 = b/60.0;
tmp1 = a/12.0 + tmp2/12.0;
tmp4 = d/60.0;
tmp3 = c/12.0 + tmp4/12.0;
if(a==c)
{
if(d>=b)
{
if(tmp1-tmp2> && tmp4-tmp3>)
{
ans = ;
}
else
ans = ;
}
else
{
ans = ;
if(tmp1 - tmp2 > )
ans++;
if(tmp4-tmp3>)
ans ++;
}
}
else if(a<c)
{
ans = c-a-;
if(tmp1 - tmp2 > )
ans++;
if(tmp4 - tmp3 > )
ans++;
}
else
{
ans = -a + c -;
if(tmp1 - tmp2 > )
ans++;
if(tmp4 - tmp3>)
ans++;
}
printf("%2d\n",ans);
}
printf("End of program 3 by team X\n");
return ;
}

ZOJ 1122 Clock(模拟)的更多相关文章

  1. UVALive - 6269 Digital Clock 模拟

    UVALive - 6269 Digital Clock 题意:时钟坏了,给你一段连续的时间,问你现在可能的时间是多少. 思路:直接模拟,他妈的居然这场就跪在了这题,卧槽,他妈的就在111行,居然多打 ...

  2. ZOJ 2680 Clock()数学

    主题链接:problemId=1680" target="_blank">http://acm.zju.edu.cn/onlinejudge/showProblem ...

  3. A - Jugs ZOJ - 1005 (模拟)

    题目链接:https://cn.vjudge.net/contest/281037#problem/A 题目大意:给你a,b,n.a代表第一个杯子的容量,b代表第二个杯子的容量,然后一共有6种操作.让 ...

  4. ZOJ 2610 Puzzle 模拟

    大模拟:枚举6个方向.检查每一个0是否能移动 Puzzle Time Limit: 2 Seconds      Memory Limit: 65536 KB Little Georgie likes ...

  5. HDU 5705 Clock(模拟,分类讨论)

    Clock Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65535/65535 K (Java/Others)Total Submi ...

  6. Capture the Flag ZOJ - 3879(模拟题)

    In computer security, Capture the Flag (CTF) is a computer security competition. CTF contests are us ...

  7. ZOJ 3705 Applications 模拟

    #pragma comment(linker, "/STACK:1024000000,1024000000") #include<cstdio> #include< ...

  8. ZOJ 3652 Maze 模拟,bfs,读题 难度:2

    http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=4842 要注意题目中两点: 1.在踏入妖怪控制的区域那一刹那,先减行动力,然后才 ...

  9. [ZOJ 1009] Enigma (模拟)

    题目链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=1009 题目大意:给你三个转换轮,只有当第一个转换轮转动一圈后第二 ...

随机推荐

  1. Oracle- 日期加减

    加法 select sysdate,add_months(sysdate,12) from dual;        --加1年 select sysdate,add_months(sysdate,1 ...

  2. win32进阶之路:给锁屏软件增加一个超链接按钮

    前言: windows下一切皆窗口,我们看到的超链接也是窗口,效果图如下: 鼠标放在赵大哥博客园主页和关于软件两个按钮上,按钮上的字体会从绿色变成红色,同时鼠标指针变为手型,点下鼠标左键就会调用默认浏 ...

  3. 数学之路(3)-机器学习(3)-机器学习算法-SVM[5]

    svm小结 1.超平面 两种颜色的点分别代表两个类别,红颜色的线表示一个可行的超平面.在进行分类的时候,我们将数据点  x 代入  f(x)  中,如果得到的结果小于 0 ,则赋予其类别 -1 ,如果 ...

  4. 修改hosts文件(判断是否为管理员/以管理员权限运行脚本)

    将以下命令保存为 HostsModify.ps1,然后执行即可 #该脚本用来添加hosts解析记录.脚本在执行的时候会判断当前用户是否为管理员,如果不是则弹出提示框口,要求输入相应密码 If (-NO ...

  5. 数据库中DDL、DML、DCL和TCP概念

    1.DDL(Data Definition Language)数据库定义语言statements are used to define the database structure or schema ...

  6. [置顶] 用Wireshark保存RTP的负载码流

    这段时间工作太忙,有些日子没写文章了,今天准备了一篇Wireshark工具的一个小功能,在验证码流的时候非常好用,闲话不说,直接说步骤: 1.打开Wireshark抓取流媒体码流,然后用RTP过滤: ...

  7. Windows ICS 服务无法启动问题解决

    防火墙打不开肯定是"windows Firewall"服务没有启动.ICS服务启动不了能够通过下面方法解决: 1.找到本地连接,单击左键--属性--共享--勾选(√)--确定,如以 ...

  8. node.js在windows下的学习笔记(9)---文件I/O模块

    开发中我们经常会有文件I/O的需求,node.js中提供一个名为fs的模块来支持I/O操作,fs模块的文件I/O是对标准POSIX函数的简单封装. 1.将"hello world" ...

  9. MySQL Cluster测试过程中的错误汇总--ERROR 1296 (HY000)等等

    参考资料: http://dev.mysql.com/doc/refman/5.1/en/mysql-cluster-privilege-distribution.html http://www.cl ...

  10. 学习笔记之JAVA多线程

    Java程序设计实用教程 by 朱战立 & 沈伟 孙鑫Java无难事 Java 多线程与并发编程专题(http://www.ibm.com/developerworks/cn/java/j-c ...