Clock

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65535/65535 K (Java/Others)
Total Submission(s): 500    Accepted Submission(s): 176

Problem Description
Given a time HH:MM:SS and one parameter , you need to calculate next time satisfying following conditions:

1. The angle formed by the hour hand and the minute hand is .
2. The time may not be a integer(e.g. 12:34:56.78), rounded down(the previous example 12:34:56).

 
Input
The input contains multiple test cases.

Each test case contains two lines.
The first line is the time HH:MM:SS.
The second line contains one integer .

 
Output
For each test case, output a single line contains test case number and the answer HH:MM:SS.
 
Sample Input

0:59:59 30 01:00:00 30
 
Sample Output

Case #1: 01:00:00 Case #2: 01:10:54

题意:给定一个时间作为起点,然后求下一个时针和分针的角度相差为k的时间。

【题意】
时间为12小时制。
告诉你一个时刻,让你输出在这个时刻之后的下一个时刻,
满足:该时刻,时针分针掐好相差某个的角度为a。
(注意,满足要求的时刻不一定是恰好以秒为单位,可以是秒与秒之间的时刻,我们可以向下取整)

【类型】
追及问题,判断

#include<stdio.h>
#include<string.h>
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<queue>
#include<stack>
#include<math.h>
#include<vector>
#include<map>
#include<set>
#include<cmath>
#include<complex>
#include<string>
#include<algorithm>
#include<iostream>
#include<string.h>
#include<algorithm>
#include<vector>
#include<stdio.h>
#include<cstdio>
#include<time.h>
#include<stack>
#include<queue>
#include<deque>
#include<map>
#define inf 0x3f3f3f3f
#define ll long long
using namespace std;
int main()
{
double h,m,s;
char pp;
int k=;
while(cin>>h>>pp>>m>>pp>>s)
{
k++;
int a;
cin>>a;
double ah=h*+m*0.5+s/120.0;
while(ah>=) ah-=;
double am=m*+s/10.0;
double x;
if(am>=ah)
{
if(am-ah<=-am+ah)
{
double o=am-ah;
if(a>o) x=a-o;
else x=-o-a;
}
else
{
double o=-am+ah;
if(a>=o) x=o+a;
else x=o-a;
}
}
else
{
if(ah-am<=-ah+am)
{
double o=ah-am;
if(a<o) x=o-a;
else x=a+o;
}
else
{
double o=-ah+am;
if(a>o) x=a-o;
else x=-a-o;
}
} x=x*/;
int ss=(int)(s+x);
int y=;
if(ss>=)
{
y=ss/;
ss=ss%;
}
int mm=m+y;
y=;
if(mm>=)
{
y=mm/;
mm=mm%;
}
int hh=h+y;
y=;
if(hh>=)
{
hh=hh%;
}
cout<<"Case #"<<k<<": ";
printf("%02d:%02d:%02d\n",hh,mm,ss);
}
return ;
}

HDU 5705 Clock(模拟,分类讨论)的更多相关文章

  1. Wannafly交流赛1 A 有理数[模拟/分类讨论]

    链接:https://www.nowcoder.com/acm/contest/69/A来源:牛客网 题目描述 有一个问题如下: 给你一个有理数v,请找到小于v的最大有理数. 但这个问题的答案对于任意 ...

  2. hdu 5511 Minimum Cut-Cut——分类讨论思想+线段树合并

    题目:http://acm.hdu.edu.cn/showproblem.php?pid=5511 题意:割一些边使得无向图变成不连通的,并且恰好割了两条给定生成树上的边.满足非树边两段一定在给定生成 ...

  3. HDU 5705 Clock (精度控制,暴力)

    题意:给定一个开始时间和一个角度,问你下一个时刻时针和分针形成这个角度是几点. 析:反正数量很小,就可以考虑暴力了,从第一秒开始暴力,直到那个角度即可,不会超时的,数目很少,不过要注意精度. 代码如下 ...

  4. hdu 5163(前缀和+分类讨论)

    Taking Bus Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total ...

  5. HDU 4609 FFT+各种分类讨论

    思路: http://www.cnblogs.com/kuangbin/archive/2013/07/24/3210565.html 其实我是懒得写了.... 一定要define int long ...

  6. HDU 5705 Clock(2016杭电女生专场1004)——角度追及问题

    题意是给出一个当前的时间和角度a,问从现在开始的下一个时针和分针形成角度a的时间是多少,时间向下取整. 分析:时针3600s走30°,故120s走1°,分针3600s走360°,故10s走1°,那么每 ...

  7. HDU 5203 Rikka with wood sticks 分类讨论

    题目链接: hdu:http://acm.hdu.edu.cn/showproblem.php?pid=5203 bc(chinese):http://bestcoder.hdu.edu.cn/con ...

  8. HDU 6627 equation (分类讨论)

    2019 杭电多校 5 1004 题目链接:HDU 6627 比赛链接:2019 Multi-University Training Contest 5 Problem Description You ...

  9. HDU 6665 Calabash and Landlord (分类讨论)

    2019 杭电多校 8 1009 题目链接:HDU 6665 比赛链接:2019 Multi-University Training Contest 8 Problem Description Cal ...

随机推荐

  1. Author Agreement

    Dear Editor,We the undersigned declare that this manuscript entitled “文章标题” is original, has not bee ...

  2. JavaScript 打印控件

    JavaScript 打印控件 github地址 https://github.com/DoersGuild/jQuery.print 使用前需要引入jQuery $("#mapDiv&qu ...

  3. Robot Framework(一)

    一. 定义 Robot Framework是一款python编写的功能自动化测试框架,具有良好的可扩展性,支持关键字驱动,可以同时测试多种类型的客户端或者接口,可以进行分布式测试执行 二. Robot ...

  4. docker建立和共享文件(服务器和docker之间的共享)

    建立序列号:sudo docker run -it domimiek/deep-base  /bin/bash   回撤后会出现一个序列号(记住) 开始:sudo docker start 序列号 当 ...

  5. hibernate框架环境搭建与使用

    搭建环境 一.新建一个项目 , 导包   一个是hibernate的jar包,一个是jdbc的jar包 hibernate的jar包 这些jar包全部导入 二.配置Hibernate. 1.建立hib ...

  6. MongoDB 高可用集群架构简介

    在大数据的时代,传统的关系型数据库要能更高的服务必须要解决高并发读写.海量数据高效存储.高可扩展性和高可用性这些难题.不过就是因为这些问题Nosql诞生了. 转载自严澜的博文——<如何搭建高效的 ...

  7. canvas操作图片,进行面板画图,旋转等

    HTML5 <canvas> 标签用于绘制图像(通过脚本,通常是 JavaScript). 不过,<canvas> 元素本身并没有绘制能力(它仅仅是图形的容器) - 您必须使用 ...

  8. 2017.11.13 python+ Jlink+EFM32 批量烧录

    1 Add whl files to Python a. install the  environment variable of path b . useing the CMD command  : ...

  9. 从无到有开发自己的Wordpress博客主题---运行环境准备

    目前只做本地开发,只在本地搭建测试环境,最后会在服务器的CentOS中搭建正式环境,我使用的是Mac,最简单的办法就是安装MAMP. 1.下载并安装MAMP 下载地址:https://www.mamp ...

  10. Unity3d 相关文档

    Unity3D研究院之处理摄像机跟随避免相机穿墙拉近或透明的方法 http://www.apkbus.com/android-498-1.html