【水枚举】#83 A. Palindromic Times

A. Palindromic Times
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output

Tattah is asleep if and only if Tattah is attending a lecture. This is a well-known formula among Tattah's colleagues.

On a Wednesday afternoon, Tattah was attending Professor HH's lecture. At 12:21, right before falling asleep, he was staring at the digital watch around Saher's wrist. He noticed that the digits on the clock were the same when read from both directions i.e. a palindrome.

In his sleep, he started dreaming about such rare moments of the day when the time displayed on a digital clock is a palindrome. As soon as he woke up, he felt destined to write a program that finds the next such moment.

However, he still hasn't mastered the skill of programming while sleeping, so your task is to help him.

Input

The first and only line of the input starts with a string with the format "HH:MM" where "HH" is from "00" to "23" and "MM" is from "00" to "59". Both "HH" and "MM" have exactly two digits.

Output

Print the palindromic time of day that comes soonest after the time given in the input. If the input time is palindromic, output the soonest palindromic time after the input time.

Sample test(s)
input
12:21
output
13:31
input
23:59
output
00:00

题意是说,电子钟的小时和分钟有时会形成回文序列,比如1221,0550之类的,给定一个现在的时间,问下一个回文时间是什么时候。

反正没多少,直接枚举出来呗~ (需要注意的是,23:32之后的时间会推到下一天的00:00去)

Code:

#include <cstdio>
#include <string>
#include <cstring> 
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;
// http://codeforces.com/contest/108
// Palindromic Times
int hor[]={0, 1, 2, 3, 4, 5,10,11,12,13,14,15,20,21,22,23};
int mie[]={0,10,20,30,40,50,1 ,11,21,31,41,51, 2,12,22,32};

int main()
{
	char maohao;
	int h,m;
	cin>>h>>maohao>>m;
	for(int i=0;i<16;i++)
	{
		if((hor[i]==h && mie[i]>m) || hor[i]>h)
		{
			if(hor[i]<10)cout<<"0";
			cout<<hor[i]<<":";
			if(mie[i]<10)cout<<"0";
			cout<<mie[i]<<endl;
			return 0;
		}
	}
	cout<<"00:00"<<endl;
	return 0;
} 





  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

糖果天王

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值