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\n", hh, mm); // sysp; } int main() { input(); return 0; }
低调做人,高调做事。
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 基于Microsoft.Extensions.AI核心库实现RAG应用
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
· 开发者必知的日志记录最佳实践
· SQL Server 2025 AI相关能力初探
· Linux系列:如何用 C#调用 C方法造成内存泄露
· 终于写完轮子一部分:tcp代理 了,记录一下
· 震惊!C++程序真的从main开始吗?99%的程序员都答错了
· 别再用vector<bool>了!Google高级工程师:这可能是STL最大的设计失误
· 单元测试从入门到精通
· 【硬核科普】Trae如何「偷看」你的代码?零基础破解AI编程运行原理