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. excel 拖拽计算时,固定一个数

    $ 表示静态引用(也叫绝对引用)的意思.即固定引用的单元格的行或列. $A1即固定列为A,$A$2即固定引用为A列2行的单元格. A$3则只固定引用为第三行. 我们在使用excel拖拽计算时,常遇到这 ...

  2. java中的char类型所占空间

    java中统一使用unicode编码,所以每个字符都是2个字节16位.unicode包括中文,所以对String类计算长度的时候,一个中文和一个英文都是一个长度.String voice = &quo ...

  3. Confluence 6 配置系统属性

    在这个页面中描述 Confluence 启动时如何设置 Java 属性和其他选项. 请查看 How to fix out of memory errors by increasing availabl ...

  4. vue.js相关资料

    1.https://cn.vuejs.org/v2/guide/ (中文文档)

  5. tomcat学习篇

    要求: 为Apache HTTP Server服务器添加JSP网页支持. 能够访问Tomcat容器的Web管理界面,以便管理各种JSP.Servelet应用. u 知识提示 在各种企业级网站应用系统中 ...

  6. ubuntu 安装python3.7 以及安装pip3 出现Command '('lsb_release', '-a')' returned non-zero exit status 1问题解决

    最近因为电脑重装,东西全没了,总计一下最近重装环境的过程. 如果没有安装包,请下载: wget http://www.python.org/ftp/python/3.7.0/Python-3.7.0. ...

  7. ASP.NET MVC性能优化(实际项目中)

    前言 在开发中为了紧赶项目进度而未去关注性能的问题,在项目逐渐稳定下来后发现性能令人感到有点忧伤,于是开始去关注这方面,本篇为记录在开发中遇到的问题并解决,不喜勿喷.注意:以下问题都是在移动端上出现, ...

  8. SpringCloud教程 | 第十二篇: 断路器监控(Hystrix Dashboard)

    版权声明:本文为博主原创文章,欢迎转载,转载请注明作者.原文超链接 ,博主地址:http://blog.csdn.net/forezp. http://blog.csdn.net/forezp/art ...

  9. 如何将桌面的路径定义到其它盘符,如d:\users\桌面

    首先要在“开始”——“运行”内输入“regedit”打开注册表编辑器,然后要在“文件”下拉菜单中的“导出”功能备份好注册表,以防万一,接着在左侧窗口依次打开: HKEY_CURRENT_USER\So ...

  10. 【数据库】python访问mysql

    import MySQLdb 所有的数据库遵循相同的python database API 需要建立connection对象连接数据库,之后建立cursor对象处理数据. conn = MySQLdb ...