码迷,mamicode.com
首页 > 其他好文 > 详细

[Codeforces 816A]Karen and Morning

时间:2017-08-19 20:08:21      阅读:115      评论:0      收藏:0      [点我收藏+]

标签:log   code   return   size   bsp   force   ++i   时间   clu   

题目大意:给你一个时间(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;
		}
	}
}

 

[Codeforces 816A]Karen and Morning

标签:log   code   return   size   bsp   force   ++i   时间   clu   

原文地址:http://www.cnblogs.com/Mrsrz/p/7397517.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!