ZOJ 1122 Clock(模拟)
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(模拟)的更多相关文章
- UVALive - 6269 Digital Clock  模拟
		
UVALive - 6269 Digital Clock 题意:时钟坏了,给你一段连续的时间,问你现在可能的时间是多少. 思路:直接模拟,他妈的居然这场就跪在了这题,卧槽,他妈的就在111行,居然多打 ...
 - ZOJ 2680 Clock()数学
		
主题链接:problemId=1680" target="_blank">http://acm.zju.edu.cn/onlinejudge/showProblem ...
 - A - Jugs ZOJ - 1005 (模拟)
		
题目链接:https://cn.vjudge.net/contest/281037#problem/A 题目大意:给你a,b,n.a代表第一个杯子的容量,b代表第二个杯子的容量,然后一共有6种操作.让 ...
 - ZOJ 2610 Puzzle 模拟
		
大模拟:枚举6个方向.检查每一个0是否能移动 Puzzle Time Limit: 2 Seconds Memory Limit: 65536 KB Little Georgie likes ...
 - HDU 5705 Clock(模拟,分类讨论)
		
Clock Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65535/65535 K (Java/Others)Total Submi ...
 - Capture the Flag ZOJ - 3879(模拟题)
		
In computer security, Capture the Flag (CTF) is a computer security competition. CTF contests are us ...
 - ZOJ 3705 Applications 模拟
		
#pragma comment(linker, "/STACK:1024000000,1024000000") #include<cstdio> #include< ...
 - ZOJ 3652 Maze 模拟,bfs,读题 难度:2
		
http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=4842 要注意题目中两点: 1.在踏入妖怪控制的区域那一刹那,先减行动力,然后才 ...
 - [ZOJ 1009] Enigma (模拟)
		
题目链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=1009 题目大意:给你三个转换轮,只有当第一个转换轮转动一圈后第二 ...
 
随机推荐
- 《Effect Java》 归纳总结
			
目录: 一.创建和销毁对象 (1 ~ 7) 二.对于所有对象都通用的方法 (8 ~ 12) 三.类和接口 (13 ~ 22) 四.泛型 (23 ~ 29) 五.枚举和注解 (30 ~ 37) 六.方法 ...
 - angular中的promise
			
angular中的promise用法 标签(空格分隔): angular 前言 Promise其实是一个规范,用类似then().then()这样的链式调用形式来处理因为异步带来意大利面条式的代码(多 ...
 - win2008下c#调用directshow问题
			
打开摄像头时报错 网上查 说缺少qedit.dll,下载后注册也不行. 最后安装暴风影音,测试ok
 - PHP 文件包含之文件路径截断(转)
			
PHP 文件包含之文件路径截断 以下是网络摘要: 1. 本来还以为挖到金矿了,跟黑哥交流后发现只能应用于Win32平台,使这个BUG的威力暴减,基本没有太大危害了,因为在WIN32平台使用PHP的实在 ...
 - 创建性能监视器(logman)
			
在本地计算机上抓取性能信息 Logman.exe create counter Perf-1Second -f bincirc -max 500 -c "\Processor(*)\% Pr ...
 - Nginx加多个tomcat实现负载均衡,动静分离
			
一:Nginx+Tomcat的动静分离 所谓动静分离就是通过nginx(或apache等)来处理用户端请求的图片.html等静态的文件,tomcat(或weblogic)处理jsp.do等动态文件,从 ...
 - android有点纠结的小问题
			
1.点击一个listview的item,以popupwindow的形式展示一个菜单.popupwindow以动画的形式展现,可一直没有预期的效果 解决方案: popupWindow.setBackgr ...
 - ios开发——实战OC篇&FMDB详解
			
FMDB详解 前一篇文章中我们介绍的SQLite的使用,在iOS中原生的SQLite API在使用上相当不友好. 于是,就出现了一系列将SQLite API进行封装的库,例如FMDB.Plausibl ...
 - Linux性能实时监测工具 Netdata
			
http://www.oschina.net/p/netdata?fromerr=hjJMgUjE#rd
 - 用antlr文法编写的hermit swrl规则(分享)
			
/* * To change this license header, choose License Headers in Project Properties. * To change this t ...