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. combo

    什么是combo 上一节中我们有一行代码: <script src="http://g.tbcdn.cn/kissy/k/1.4.8/??seed-min.js,import-styl ...

  2. Python SQL相关操作

    环境 Anaconda3 Python 3.6, Window 64bit 目的 从MySQL数据库读取数据,进行数据查询.关联 代码 # -*- coding: utf-8 -*- "&q ...

  3. [eShopOnContainers 学习系列] - 03 - 在远程 Ubuntu 16.04 上配置开发环境

    直接把 md 粘出来了,博客园的富文本编辑器换成 markdown,没啥效果呀 ,先凑合吧.实在不行换地方   # 在远程 Ubuntu 16.04 上配置开发环境 ## 零.因 为什么要用这么麻烦的 ...

  4. Codeforces Round #394 (Div. 2) B. Dasha and friends

    B. Dasha and friends time limit per test:2 seconds memory limit per test:256 megabytes input:standar ...

  5. Centos6.8 JDK配置

    记录一下在这个服务器配置的过程 ssh root@IP Password --------------------------------------------------------------- ...

  6. 【html】html笔记综合

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

  7. windows 改路径有小差异

    https://jingyan.baidu.com/article/5552ef473e2df6518ffbc916.html cmd是windows下一个非常常用的工具,但是它默认的地址却是不变的. ...

  8. android开发之eclipse调试debug模式详解

     之前我写了一个相关的帖子,但是今天看了一个还是写的比我详细,于是我拿过来和大家分享. 1.在程序中添加一个断点 如果所示:在Eclipse中添加了一个程序断点 在Eclipse中一共有三种添加断 ...

  9. 使用redis计数来控制单位时间内对某接口的访问量,防止刷验证码接口之类的

    使用自定义注解的方式,在需要被限制访问频率的方法上加注解即可控制. 看实现方式,基于springboot,aop,redis. 新建Springboot工程,引入redis,aop. 创建注解 pac ...

  10. canvas 创建颜色渐变柱状图

    最终结果: 代码: <!DOCTYPE html> <html> <head lang="en"> <meta charset=" ...