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. gitlab 备份

    gitlab 备份 gitlab-rake gitlab:backup:create 执行之后,就会生成一个备份文件 [root@iZuf6dztc469onegfborf5Z backups]# l ...

  2. 学习mybatis时出现了java.io.IOException: Could not find resource EmployeeMapper.xml

    使用mybatis时出现了Could not find resource EmployeeMapper.xml和Could not find resource mybatis-config.xml两种 ...

  3. yii2:多表查询

    啥都不说了,上代码: $list = static::find() ->leftJoin('book', 'book.RID = prices.RID')->select('prices. ...

  4. colorlog的三个例子

    例1:默认的log_colors import logging from logging.handlers import RotatingFileHandler from colorlog impor ...

  5. hdu 5978 To begin or not to begin(概率,找规律)

    To begin or not to begin Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java ...

  6. C++中static与const成员

    一.static成员 (1)static数据成员 static数据成员的创建是为了对象之间的共享和沟通,具有以下特点: 1.1 static数据成员属于类,只占一份空间(不像普通数据成员每个对象中都有 ...

  7. opencv:图像模糊处理

    接口: blur(sourceImage,dstImage,Size(,)); // 图像模糊处理 示例代码: #include <opencv.hpp> #include <img ...

  8. LeetCode OJ:Intersection of Two Linked Lists(两个链表的插入)

    Write a program to find the node at which the intersection of two singly linked lists begins. For ex ...

  9. 【html】html笔记综合

    基本标签与属性 <html>全部 <body>主体 <h1>标题 <p>段落 <br>空行,一般都会额外添加,并不总是需要自己添加,可以在& ...

  10. QWidget类参考

    QWidget类是所有用户界面对象的基类. 详情请见…… #include <qwidget.h> 继承QObject和QPaintDevice. 被QButton.QFrame.QDia ...