描述

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

循环式暴力搜索。

做水题好快乐。

代码:

#include <bits/stdc++.h>using namespace std;
int v[5];
int shi=-1,fen=-1;
void work(int q,int w,int e,int r)
{int sh=q*10+w;int fe=e*10+r;if(sh<=23&&fe<=59){if(sh>shi||(sh==shi&&fe>fen)){shi=sh;fen=fe;}}
}
int shu(int x)
{int ans=0;while(x){x=x/10;ans++;}if(ans==2)return 1;return 0;
}
int main()
{int a[4];for(int i=0;i<4;i++){scanf("%d",&a[i]);}for(int i=0;i<4;i++){memset(v,0,sizeof(v));v[i]=1;for(int j=0;j<4;j++){if(v[j])continue;v[j]=1;for(int k=0;k<4;k++){if(v[k])continue;v[k]=1;for(int l=0;l<4;l++){if(v[l])continue;v[l]=1;work(a[i],a[j],a[k],a[l]);v[l]=0;}v[k]=0;}v[j]=0;}v[i]=0;}if(shi==-1&&fen==-1){printf("NOT POSSIBLE\n");}else{if(shu(shi)){printf("%d:",shi);}else printf("0%d:",shi);if(shu(fen)){printf("%d\n",fen);}else printf("0%d\n",fen);}return 0;
}

#1408 : The Lastest Time相关推荐

  1. HihoCoder 1408 The Lastest Time

    1408 : The Lastest Time 时间限制:10000ms 单点时限:1000ms 内存限制:256MB 描述 What is latest time you can make with ...

  2. textblob 情感分析_使用TextBlob进行远程学习的推文中的情感分析

    textblob 情感分析 Hi everyone, 嗨,大家好, The Covid19 Pandemic brought about distance learning in the 2020 a ...

  3. *1408素数回文数的个数

    题目链接:http://ybt.ssoier.cn:8088/problem_show.php?pid=1408 1 #include<cstdio> 2 #include<cstr ...

  4. 信息学奥赛一本通(1408:素数回文数的个数)

    1408:素数回文数的个数 时间限制: 1000 ms         内存限制: 65536 KB 提交数: 14465     通过数: 9201 [题目描述] 求11到n之间(包括n),既是素数 ...

  5. oracle 1408,Oracle 11.2.0.2 Patch 说明

    今天小看了一下Oracle 11.2.0.2 Patch, patch number: 10098816.Patch最大的6G多. 杯具中. https://www.cndba.cn/Dave/art ...

  6. 软件版本(release、stable、lastest)的区别

    snapshot(快照),也即开发版,我们创建maven项目时,编辑器会自动给我们填入 1.0-SNAPSHOT版本,也就是1.0开发版,这个版本不能使用,因为该版本处于开发的过程,所以运行时会不时地 ...

  7. The Lastest Time

    题目1 : The Lastest Time 时间限制:10000ms 单点时限:1000ms 内存限制:256MB 描述 What is latest time you can make with ...

  8. 阿里云docker 环境构建镜像的:lastest not found 问题

    在按照 Docker练习场 操作时,pull 遇到 lastest not found ,是自己的镜像没有这个版本号,到"镜像版本"看也是没有的: 把pull 换成已有镜像,如:r ...

  9. Orchestrator Lastest Slave选择逻辑“不合理“导致的数据丢失问题

    Orchestrator Lastest Slave选择逻辑"不合理"导致的数据丢失问题 首先说明, "不合理"只是站在个人角度的结论. 到底合理不合理, 我说 ...

最新文章

  1. 满足极高读写性能需求的Key-Value数据库
  2. C#-析构方法与构造方法 087
  3. php随机数字不重复使等式成立_当随机数遇上量子
  4. 《C++ Primer》7.1.3节练习
  5. 【渝粤题库】陕西师范大学200221 中国思想史 作业(高起专)
  6. stacking模型融合_【干货】比赛后期大招之stacking技术分享
  7. 用C#语言实现记事本
  8. 蓝桥杯等差素数列(暴力)
  9. wagtail 实现中英文
  10. uniapp生成海报
  11. 头条号发视频有收益吗,头条号发视频就有收益吗
  12. 2021年一次比较奇葩的 AWS 面试
  13. nvl() 和nvl2()
  14. K8s系列之:搭建高可用K8s v1.23.5集群详细步骤,3个master节点,3个Node节点
  15. 前端使用jsencrypt的rsa加密算法加密信息后,在openresty搭建的网关处进行密文解密遇到的坑
  16. android勒索软件,安卓勒索软件最新伎俩
  17. submit()和execute()区别
  18. 玩转华为ENSP模拟器系列 | 配置设备用SNMPv3 USM用户与网管通信示例
  19. 新房装修|厨房台面给我做高了10公分,做饭不方便
  20. TJOI2013 黄金矿工(01背包改)

热门文章

  1. 解决c3p0连接数据库超时问题
  2. windows中hadoop报错org.apache.hadoop.io.nativeio.NativeIO$Windows.access0(Ljava/lang/String;I)Z
  3. 如何使用WinAuth算出US开头的暴雪战网安全令序列号
  4. java.io.IOException: The temporary upload location [C:\Users\...\ROOT] is not valid
  5. 计算机画图怎样更改文字,如何使用最简单的画图工具修改图片或者文字
  6. AI教程之 Stable Diffusion在自己电脑上运行稳定的AI自动艺术创作
  7. 人工智能教程 - 1.1.1 什么是神经网络
  8. 万花筒大赛获奖VR电影将亮相VR科学节,约否?
  9. 返程高峰正在来临,百度上线新型肺炎患者同行者查询服务
  10. Git 提示Your branch is up-to-date with 'origin/master'