zoukankan      html  css  js  c++  java
  • hiho一下 第207周

    题目1 : The Lastest Time

    时间限制:10000ms
    单点时限:1000ms
    内存限制:256MB

    描述

    What is latest time you can make with 4 digits A, B, C and D?

    For example if the 4 digits are 1, 0, 0, 0, you can make 4 times with them: 00:01, 00:10, 01:00, 10:00. The lastest time will be 10:00. Note a valid time is between 00:00 and 23:59.

    输入

    One line with 4 digits A, B, C and D, separated by a space. (0 <= A, B, C, D <= 9)

    输出

    Output the lastest time in the format "hh:mm". If there is no valid time output NOT POSSIBLE.  

    样例输入
    0 9 0 0
    样例输出
    09:00

    这应该是我做过最简单的hiho一下了。。

    // Asimple
    #include <bits/stdc++.h>
    #define debug(a) cout<<#a<<" = "<<a<<endl
    #define sysp system("pause")
    using namespace std;
    typedef long long ll;
    const int maxn = 1000 + 5;
    const int INF = 1e9+5;
    ll T, n, sum, num, m, t, len, k;
    int a[4];
    
    bool check(int hh, int mm, int th, int tm) {
        if( hh<th ) return true;
        else if( hh == th ) {
            return mm<tm;
        }
        return false;
    }
    
    void input() {
       for(int i=0; i<4; i++) scanf("%d", &a[i]);
       int hh = -1, mm = -1;
       sort(a, a+4);
       do{
           int th = a[0]*10+a[1], tm = a[2]*10+a[3];
           if( th<24 && tm<60 ) {
               if( check(hh, mm, th, tm) ) {
                   hh = th;
                   mm = tm;
               }
           }
       }while( next_permutation(a, a+4));
       if( hh == -1 && mm == -1 ) puts("NOT POSSIBLE");
       else printf("%02d:%02d
    ", hh, mm);
       // sysp;
    }
     
    int main() {
        input();
        return 0;
    }
  • 相关阅读:
    HTML--1标签表格
    HTML--4格式布局
    HTML--3css样式表
    快速制作网页的方法
    表单
    表单练习——邮箱注册
    斐波那契数列
    0125 多线程 继承Thread 练习
    Hash(哈希)
    [COI2007] [luogu P1823] Patrik 音乐会的等待 解题报告 (单调栈)
  • 原文地址:https://www.cnblogs.com/Asimple/p/9198314.html
Copyright © 2011-2022 走看看