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. mybatis引入dtd约束

    window->preferences,然后寻找xml catalog,点击add如下所示 将dtd网址复制到key中 key type选择uri,选择dtd的下载路径.

  2. python学习笔记(接口自动化框架 V1.0)

    之前是利用python自带的unittest测试框架 这次自己设计一个 之后再一点点往里面加功能 (ps:当然这个框架真的是很简单..很简单...很简单...) excel文件格式: #!/usr/b ...

  3. .Net Core使用jexus配置https

    今天搞了一下怎么从http换成https,写一篇博客记录该过程.关于jexus的安装和使用请看我之前的一篇博客<Jexus部署Asp.Net Core项目>,唯一的不同是,将jexus升级 ...

  4. Html工具类

    import java.io.IOException; import java.io.PrintWriter; import javax.servlet.http.HttpServletRespons ...

  5. TCP和Http的区别!(转) 真心有帮助!!!

    一.From:http://thisliy.javaeye.com/blog/710122 http://wenku.baidu.com/view/14a30d0102020740be1e9b84.h ...

  6. puppet笔记

    简介: puppet是一种Linux.Unix平台的集中配置管理系统,使用ruby语言,可管理配置文件.用户.cron任务.软件包.系统服务等.puppet把这些系统实体称之为资源,puppet的设计 ...

  7. 28-THREE.JS 扇形圆形

    <!DOCTYPE html> <html> <head> <title></title> <script src="htt ...

  8. LeetCode OJ:Remove Duplicates from Sorted Array(排好序的vector去重)

    Given a sorted array, remove the duplicates in place such that each element appear only once and ret ...

  9. javascript: 代码优化

    一.避免全局查找 在一个函数中会用到全局对象存储为局部变量来减少全局查找,因为访问局部变量的速度要比访问全局变量的速度更快些 function search() { //当我要使用当前页面地址和主机域 ...

  10. C++复制构造函数的实现

    复制构造函数是一种特殊的构造函数,有一般构造函数的特性.它的功能是用一个已知的对象来初始化一个被创建的同类对象.复制构造函数的参数传递方式必须按引用来进行传递,请看实例: #include <i ...