[Codeforces 816A]Karen and Morning

题目大意:给你一个时间(hh:mm),求最少经过多少分钟才能使这个时间变成回文。

解题思路:模拟,先判断0的情况,然后每过1分钟判断一次即可。

C++ Code:

#include<cstdio>
int main(){
	int h,m;
	scanf("%d:%d",&h,&m);
	if(h==m%10*10+m/10){
		puts("0");
		return 0;
	}
	for(int i=1;;++i){
		++m;
		if(m==60){
			m=0;
			++h;
			if(h==24)h=0;
		}
		if(h==m%10*10+m/10){
			printf("%d\n",i);
			return 0;
		}
	}
}

 

posted @ 2017-08-19 18:28  Mrsrz  阅读(181)  评论(0编辑  收藏  举报