HDU 4177 模拟时间问题
Avoiding a disaster
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 211 Accepted Submission(s): 101
likes to be punctual. So much so that he always keeps three watches
with him, so that he can be sure exactly what the time is. However,
Percy's having a bad day. He found out that one of his watches was
giving the wrong time. What's worse, when he went to correct the watch,
he corrected the wrong one! That is, one watch was running x minutes
behind (where x <= 480) and he wound one of the other watches x
minutes forward. He now has three watches reading three different times,
and hence is in serious danger of being tardy. Can you help Percy by
writing a program that takes in the three times displayed on the watches
and returns the correct time?
<
100). Each of the following T lines contains one test case, made up of
three readings, separated by single space characters: H1:M1 H2:M2 H3:M3
In each reading H1,H2,H3 represent the hours displayed (0 < H1,H2,H3
< 13), and M1,M2,M3 represent the minutes displayed (0 <= M1,M2,M3
< 60).
If the number of minutes is less than 10, a leading 0 is added.
correct time is Hi:Mi". If the number of minutes is less than 10, a leading 0 should be
added.
If the number of hours is less than 10, a leading 0 should NOT be
added. If it is impossible to tell the time from the three readings,
print the string: "Look at the sun".
5:00 12:00 10:00
11:59 12:30 1:01
12:00 4:00 8:00
The correct time is 12:30
Look at the sun
#include<stdio.h>
#include<string.h>
#include<math.h>
int main()
{
int t;
scanf("%d",&t);
while(t--)
{
char c1,c2,c3;
int h1,h2,h3;
char m11,m12,m21,m22,m31,m32;
scanf("%d%c%c%c",&h1,&c1,&m11,&m12);
getchar();
scanf("%d%c%c%c",&h2,&c2,&m21,&m22);
getchar();
scanf("%d%c%c%c",&h3,&c3,&m31,&m32);
int min1=,min2=,min3=;
min1=h1*+m11*+m12;
min2=h2*+m21*+m22;
min3=h3*+m31*+m32;
int p1=,p2=,p3=;
if(min1+min2==*min3&&fabs(min1-min3)<=)
p3++;
else if(min1+min3==*min2&&fabs(min1-min2)<=)
p2++;
else if(min3+min2==*min1&&fabs(min3-min1)<=)
p1++;
min1+=*;
if(min1+min2==*min3&&fabs(min1-min3)<=)
p3++;
else if(min1+min3==*min2&&fabs(min1-min2)<=)
p2++;
else if(min3+min2==*min1&&fabs(min3-min1)<=)
p1++;
min1-=*;
min2+=*;
if(min1+min2==*min3&&fabs(min1-min3)<=)
p3++;
else if(min1+min3==*min2&&fabs(min1-min2)<=)
p2++;
else if(min3+min2==*min1&&fabs(min3-min1)<=)
p1++;
min2-=*;
min3+=*;
if(min1+min2==*min3&&fabs(min1-min3)<=)
p3++;
else if(min1+min3==*min2&&fabs(min1-min2)<=)
p2++;
else if(min3+min2==*min1&&fabs(min3-min1)<=)
p1++;
min1+=*;
min2+=*;
min3-=*;
if(min1+min2==*min3&&fabs(min1-min3)<=)
p3++;
else if(min1+min3==*min2&&fabs(min1-min2)<=)
p2++;
else if(min3+min2==*min1&&fabs(min3-min1)<=)
p1++;
min2-=*;
min3+=*;
if(min1+min2==*min3&&fabs(min1-min3)<=)
p3++;
else if(min1+min3==*min2&&fabs(min1-min2)<=)
p2++;
else if(min3+min2==*min1&&fabs(min3-min1)<=)
p1++;
min1-=*;
min2+=*;
if(min1+min2==*min3&&fabs(min1-min3)<=)
p3++;
else if(min1+min3==*min2&&fabs(min1-min2)<=)
p2++;
else if(min3+min2==*min1&&fabs(min3-min1)<=)
p1++;
min1+=*;
if(min1+min2==*min3&&fabs(min1-min3)<=)
p3++;
else if(min1+min3==*min2&&fabs(min1-min2)<=)
p2++;
else if(min3+min2==*min1&&fabs(min3-min1)<=)
p1++;
if(p1>&&p2>||p1>&&p3>||p2>&&p3>)
printf("Look at the sun\n");
else if(p1>)
{
printf("The correct time is %d:%c%c\n",h1,m11,m12);
}
else if(p2>)
{
printf("The correct time is %d:%c%c\n",h2,m21,m22);
}
else if(p3>)
{
printf("The correct time is %d:%c%c\n",h3,m31,m32);
}
}
return ;
}
HDU 4177 模拟时间问题的更多相关文章
- hdu 2079 选课时间
hdu 2079 选课时间 题意:选的学分总和为n,并且学分为a的课有b种,总共有K(1<=k<=8)种学分不同的课,并且要选的学分最多为40:问选课方案有多少种?(学分相同的课即认为相同 ...
- hdu 4891 模拟水题
http://acm.hdu.edu.cn/showproblem.php?pid=4891 给出一个文本,问说有多少种理解方式. 1. $$中间的,(s1+1) * (s2+1) * ...*(sn ...
- hdu 5012 模拟+bfs
http://acm.hdu.edu.cn/showproblem.php?pid=5012 模拟出骰子四种反转方式,bfs,最多不会走超过6步 #include <cstdio> #in ...
- HDU 2079 选课时间(普通型 数量有限 母函数)
传送门: http://acm.hdu.edu.cn/showproblem.php?pid=2079 选课时间(题目已修改,注意读题) Time Limit:1000MS Memory Li ...
- hdu 4669 模拟
思路: 主要就是模拟这些操作,用链表果断超时.改用堆栈模拟就过了 #include<map> #include<set> #include<stack> #incl ...
- hdu 2079 选课时间(题目已修改,注意读题)
http://acm.hdu.edu.cn/showproblem.php?pid=2079 背包 #include <cstdio> #include <cstring> # ...
- 2013杭州网络赛C题HDU 4640(模拟)
The Donkey of Gui Zhou Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/O ...
- HDU 2079-课程时间(生成函数)
课程时间(标题已被修改,注意阅读题) Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Other ...
- HDU/5499/模拟
题目链接 模拟题,直接看代码. £:分数的计算方法,要用double; #include <set> #include <map> #include <cmath> ...
随机推荐
- Kibana功能一览
Overview标签 总共32个请求,最大响应时间:4.7秒 Usage标签 可以看到HTTP请求的发起时间分布 Performance and Quality 6个请求里,响应时间在100毫秒以下的 ...
- Netweaver工作进程的内存限制 VS CloudFoundry应用的内存限制
Netweaver 一个会话进程能够在堆上申请的内存大小上限, 在事务码RZ11里查看参数abap/heap_area_dia: CloudFoundry 每个应用可以在manifest.yml里定义 ...
- 学习Rust Book之写Cargo配置文件
不知道为什么这个文件就是编译不过 [package] name = "hello_world" version = "0.0.1" author = " ...
- SQL Server Profiler查询跟踪的简单使用
1.打开SQL Server Management Studio,选择工具->SQL Server Profiler,或者直接从路径:开始/程序/Microsoft SQL Server 200 ...
- 2018.6.22 Java试题测试结果
如何从有数字规律的网址抓取网页并保存在当前目录?假设网址为 http://test/0.xml,其中这个数字可以递增到100. for((i=0;i<100;++i));do wget http ...
- NET_Framework_4.0installer.rar
部署提示: 1.首先下载有关的安装程序 NET_Framework_4.0installer.rar 这是我整理好的四个软件(大致一共10MB),分别如下 WindowsInstaller-KB893 ...
- python_63_装饰器6
#decorator意思:1.装饰器 2.语法糖 import time user,passwd='qi','123' def auth(func): def wrappper(*args, **kw ...
- SQLyog点击“测试连接”后,报2058错误
问题:安装MySQL和SQLyog之后,在SQLyog中点击“测试连接”时,报2058错误. 解决:这里要确定两个问题:1 MySQL是否配置了环境变量:2 如果配置了MySQL环境变量,那么需要在c ...
- java算法面试题:有数组a[n],用java代码将数组元素顺序颠倒
package com.swift; import java.util.ArrayList; import java.util.Collections; import java.util.List; ...
- 洛谷P2468 [SDOI2010]粟粟的书架(二分答案 前缀和 主席树)
题意 题目链接 给出一个矩形,每个点都有一些值,每次询问一个子矩阵最少需要拿几个数才能构成给出的值 Sol 这题是真坑啊.. 首先出题人强行把两个题拼到了一起, 对于前$50 \%$的数据,考虑二分答 ...