A. Broken Clock

time limit per test:1 second
memory limit per test:256 megabytes
input:standard input
output:standard output

You are given a broken clock. You know, that it is supposed to show time in 12- or 24-hours HH:MM format. In 12-hours format hours change from 1 to 12, while in 24-hours it changes from 0 to 23. In both formats minutes change from 0 to 59.

You are given a time in format HH:MM that is currently displayed on the broken clock. Your goal is to change minimum number of digits in order to make clocks display the correct time in the given format.

For example, if 00:99 is displayed, it is enough to replace the second 9 with 3 in order to get 00:39 that is a correct time in 24-hours format. However, to make 00:99 correct in 12-hours format, one has to change at least two digits. Additionally to the first change one can replace the second 0 with 1 and obtain 01:39.

Input

The first line of the input contains one integer 12 or 24, that denote 12-hours or 24-hours format respectively.

The second line contains the time in format HH:MM, that is currently displayed on the clock. First two characters stand for the hours, while next two show the minutes.

Output

The only line of the output should contain the time in format HH:MM that is a correct time in the given format. It should differ from the original in as few positions as possible. If there are many optimal solutions you can print any of them.

Examples

input

24
17:30

output

17:30

input

12
17:30

output

07:30

input

24
99:99

output

09:09
 //2016.10.1
#include <iostream>
#include <cstdio>
#include <cstring> using namespace std; int main()
{
int format, hh, mm;
while(scanf("%d", &format)!=EOF)
{
scanf("%d:%d", &hh, &mm);
if(format==)
{
if(hh == )hh++;
else if(hh< || hh > )
{
if(hh% == )hh = ;
else hh %= ;
}
if(mm< || mm > )mm%=;
printf("%02d:%02d\n", hh, mm);
}else
{
if(hh< || hh > )hh%=;
if(mm< || mm > )mm%=;
printf("%02d:%02d\n", hh, mm);
}
} return ;
}

CodeForces 722A的更多相关文章

  1. CodeForces 722A Broken Clock (水题)

    题意:给定一个时间,然后改最少的数字,使得它成为12进制或者24进制. 析:24进制主要判是不是大于23,如果是把第一位变成0,12进制判是不是大于12,如果是再看第二位是不是0,是0,第一位变成1, ...

  2. 【26.34%】【codeforces 722A】Broken Clock

    time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard ou ...

  3. Codeforces水题集合[14/未完待续]

    Codeforces Round #371 (Div. 2) A. Meeting of Old Friends |B. Filya and Homework A. Meeting of Old Fr ...

  4. python爬虫学习(5) —— 扒一下codeforces题面

    上一次我们拿学校的URP做了个小小的demo.... 其实我们还可以把每个学生的证件照爬下来做成一个证件照校花校草评比 另外也可以写一个物理实验自动选课... 但是出于多种原因,,还是绕开这些敏感话题 ...

  5. 【Codeforces 738D】Sea Battle(贪心)

    http://codeforces.com/contest/738/problem/D Galya is playing one-dimensional Sea Battle on a 1 × n g ...

  6. 【Codeforces 738C】Road to Cinema

    http://codeforces.com/contest/738/problem/C Vasya is currently at a car rental service, and he wants ...

  7. 【Codeforces 738A】Interview with Oleg

    http://codeforces.com/contest/738/problem/A Polycarp has interviewed Oleg and has written the interv ...

  8. CodeForces - 662A Gambling Nim

    http://codeforces.com/problemset/problem/662/A 题目大意: 给定n(n <= 500000)张卡片,每张卡片的两个面都写有数字,每个面都有0.5的概 ...

  9. CodeForces - 274B Zero Tree

    http://codeforces.com/problemset/problem/274/B 题目大意: 给定你一颗树,每个点上有权值. 现在你每次取出这颗树的一颗子树(即点集和边集均是原图的子集的连 ...

随机推荐

  1. 【HighCharts系列教程】二、Highcharts结构及API文档

    一.你必须知道的 1.首先,HighCharts是基于Jquery框架开发的,所以需要在页面引入Jquery,具体代码是: <script type="text/javascript& ...

  2. CentOS 6.4 x64 Cacti 监控安装配置

    Cacti 监控安装配置   环境:   安装Cacti 的服务器   Linux 6.4 x64   ip 10.8.8.11     一: 配置iptables , selinux     vi ...

  3. 机器学习模型 bias 和 variance 的直观判断

    假设我们已经训练得到 一个模型,那么我们怎么直观判断这个 模型的 bias 和 variance? 直观方法: 如果模型的 训练错误 比较大,并且 验证错误 和 训练错误 差不多一样,都比较大,我们就 ...

  4. 3个人一起写的EI论文可以检索到啦~ --> Exploring the use of a 3D Virtual Environment in Chinese Cultural Transmission

    <a href='http://www.engineeringvillage.com/blog/document.url?mid=cpx_10ed754f14b5b7381b6M764b1017 ...

  5. Extjs4中的布局

    布局用于定义容器如何组织内部子元素和控制子元素的大小.在一个应用程序中,作为定义容器的组织形式,布局是一个十分重要的组件.是显示单个子元素?还是垂直或水平显示多个子元素?这些均由布局来定义.并且布局将 ...

  6. HTML中meta的应用

    meta是用来在HTML文档中模拟HTTP协议的响应头报文.meta 标签用 于网页的<head>与</head>中,meta 标签的用处很多.meta 的属性有两种:name ...

  7. kvm下Windows激活方式小计

    使用kvm创建widnwos镜像模板,镜像模板默认是已经激活的正版系统,但是使用程序拷贝部署到不同的机器后发现已经激活的系统变成未激活状态,我们需求就是需要拷贝到不同的机器也能显示是正版系统 网上找了 ...

  8. 关于IP选项

    源:关于IP选项 校验和算法

  9. LPC2478的硬件IIC使用

    LPC2478的IIC使用 LPC2478带有三个IIC接口,每个IIC都可以工作在主机或者从机模式下,LPC的IIC的架构是一种状态机的形式,在不同的的时间做不同的工作之后有不同的状态来表示, 简单 ...

  10. fastcgi_param 详解

    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;#脚本文件请求的路径 fastcgi_param QUERY_STRI ...