Codeforces Round #419 A

A. Karen and Morning

题意:给你一个时间,求最少多少分钟后,表示时间的字符串是一个回文串,时间是24小时制,但是24:00 表示为00:00

思路:暴力最多一天就一定会出现回文,所以最多24*60*60   xjb写就可以了

AC代码:

#include "iostream"
#include "string.h"
#include "stack"
#include "queue"
#include "string"
#include "vector"
#include "set"
#include "map"
#include "algorithm"
#include "stdio.h"
#include "math.h"
#define bug(x) cout<<x<<" "<<"UUUUU"<<endl;
#define mem(a) memset(a,0,sizeof(a))
using namespace std;
const int N=2e5+100;
int a,b,c,d;
int check(){
    if((b/10)==d && (b%10)==c)
        return 1;
    return 0;
}
int main(){
    char s;
    int ans=0;
    cin>>b>>s>>c;
    d=c%10;
    c=c/10;
    if(check()){
        cout<<ans<<endl;
        return 0;
    }
    while(!check()){
        ans++;
        d+=1;
        if(d>=10){
            c++;
            d=0;
        }
        if(c>=6){
            b++;
            c=0;
        }
        if(b>=24){
            b=0;
        }
    }
    cout<<ans<<endl;
    return 0;
}
原文地址:https://www.cnblogs.com/max88888888/p/7091826.html