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 = + ;
const int INF = 1e9+;
ll T, n, sum, num, m, t, len, k;
int a[]; 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=; i<; i++) scanf("%d", &a[i]);
int hh = -, mm = -;
sort(a, a+);
do{
int th = a[]*+a[], tm = a[]*+a[];
if( th< && tm< ) {
if( check(hh, mm, th, tm) ) {
hh = th;
mm = tm;
}
}
}while( next_permutation(a, a+));
if( hh == - && mm == - ) puts("NOT POSSIBLE");
else printf("%02d:%02d\n", hh, mm);
// sysp;
} int main() {
input();
return ;
}
上一篇:Python访问MySQL数据库并实现其增删改查功能


下一篇:Spring+SpringMVC+MyBatis+easyUI整合基础篇(九)版本控制