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 加持,快人一步
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
· 基于Microsoft.Extensions.AI核心库实现RAG应用
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
· 开发者必知的日志记录最佳实践
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· Manus的开源复刻OpenManus初探
· AI 智能体引爆开源社区「GitHub 热点速览」
· 从HTTP原因短语缺失研究HTTP/2和HTTP/3的设计差异
· 三行代码完成国际化适配,妙~啊~