• 【codeforces 816A】Karen and Morning


    【题目链接】:http://codeforces.com/contest/816/problem/A

    【题意】

    让你一分钟一分钟地累加时间;
    问多长时间以后是个回文串;

    【题解】

    reverse之后如果和原串相同,则为回文串;
    模拟就好

    【Number Of WA

    0

    【完整代码】

    #include <bits/stdc++.h>
    using namespace std;
    #define lson l,m,rt<<1
    #define rson m+1,r,rt<<1|1
    #define LL long long
    #define rep1(i,a,b) for (int i = a;i <= b;i++)
    #define rep2(i,a,b) for (int i = a;i >= b;i--)
    #define mp make_pair
    #define pb push_back
    #define fi first
    #define se second
    #define ms(x,y) memset(x,y,sizeof x)
    #define Open() freopen("F:\rush.txt","r",stdin)
    #define Close() ios::sync_with_stdio(0)
    
    typedef pair<int,int> pii;
    typedef pair<LL,LL> pll;
    
    const int dx[9] = {0,1,-1,0,0,-1,-1,1,1};
    const int dy[9] = {0,0,0,-1,1,-1,1,-1,1};
    const double pi = acos(-1.0);
    const int N = 110;
    
    int n;
    int h,m;
    
    string zh(int h,int m){
        int a,b,c,d;
        a = h/10;
        string s = "";
        s+= (char) a + '0';
        b = h%10;
        s+= (char) b + '0';
        s+=':';
        c = m/10;
        s+=(char) c+'0';
        d = m%10;
        s+=(char) d+'0';
        return s;
    }
    
    int main(){
        //Open();
        Close();
        scanf("%d:%d",&h,&m);
        int now = 0;
        while (1){
            string s = zh(h,m);
            string ts = s;
            reverse(ts.begin(),ts.end());
            if (ts==s){
                cout << now<<endl;
                return 0;
            }
            now++;
            m++;
            if (m>59){
                m = 0;
                h++;
                if (h>23) h = 0;
            }
        }
        return 0;
    }
  • 相关阅读:
    首页列表显示全部问答,完成问答详情页布局。
    制作首页的显示列表。
    管理信息系统 课程设计
    期末作品检查
    数据迁移
    模型分离(选做)
    密码保护
    实现搜索功能
    完成个人中心—导航标签
    个人中心标签页导航
  • 原文地址:https://www.cnblogs.com/AWCXV/p/7626247.html
Copyright © 2020-2023  润新知