CodeForces 722A Broken Clock (水题)
题意:给定一个时间,然后改最少的数字,使得它成为12进制或者24进制。
析:24进制主要判是不是大于23,如果是把第一位变成0,12进制判是不是大于12,如果是再看第二位是不是0,是0,第一位变成1,不是第一位变成0,
如果等于0,第一位变成1,至于分钟,只要判是不是大于59,是把第一位变成0.
代码如下:
#pragma comment(linker, "/STACK:1024000000,1024000000")
#include <cstdio>
#include <string>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <cstring>
#include <set>
#include <queue>
#include <algorithm>
#include <vector>
#include <map>
#include <cctype>
#include <cmath>
#include <stack>
//#include <tr1/unordered_map>
#define freopenr freopen("in.txt", "r", stdin)
#define freopenw freopen("out.txt", "w", stdout)
using namespace std;
//using namespace std :: tr1; typedef long long LL;
typedef pair<int, int> P;
const int INF = 0x3f3f3f3f;
const double inf = 0x3f3f3f3f3f3f;
const LL LNF = 0x3f3f3f3f3f3f;
const double PI = acos(-1.0);
const double eps = 1e-8;
const int maxn = 1e5 + 5;
const LL mod = 1e9 + 7;
const int N = 1e6 + 5;
const int dr[] = {-1, 0, 1, 0, 1, 1, -1, -1};
const int dc[] = {0, 1, 0, -1, 1, -1, 1, -1};
const char *Hex[] = {"0000", "0001", "0010", "0011", "0100", "0101", "0110", "0111", "1000", "1001", "1010", "1011", "1100", "1101", "1110", "1111"};
inline LL gcd(LL a, LL b){ return b == 0 ? a : gcd(b, a%b); }
inline int gcd(int a, int b){ return b == 0 ? a : gcd(b, a%b); }
int n, m;
const int mon[] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
const int monn[] = {0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
inline int Min(int a, int b){ return a < b ? a : b; }
inline int Max(int a, int b){ return a > b ? a : b; }
inline LL Min(LL a, LL b){ return a < b ? a : b; }
inline LL Max(LL a, LL b){ return a > b ? a : b; }
inline bool is_in(int r, int c){
return r >= 0 && r < n && c >= 0 && c < m;
} int main(){
while(scanf("%d", &n) == 1){
string s;
cin >> s;
int h = (s[0] - '0') * 10 + s[1] - '0';
int m = s[3] - '0';
if(m > 5) s[3] = '0';
if(n == 24){
if(h > 23) s[0] = '0';
}
else{
if(h > 12){
if(s[1] != '0') s[0] = '0';
else s[0] = '1';
}
if(!h) s[0] = '1';
}
cout << s << endl;
}
return 0;
}
CodeForces 722A Broken Clock (水题)的更多相关文章
- Intel Code Challenge Elimination Round (Div.1 + Div.2, combined) A. Broken Clock 水题
A. Broken Clock 题目连接: http://codeforces.com/contest/722/problem/A Description You are given a broken ...
- Codeforces Gym 100531G Grave 水题
Problem G. Grave 题目连接: http://codeforces.com/gym/100531/attachments Description Gerard develops a Ha ...
- codeforces 706A A. Beru-taxi(水题)
题目链接: A. Beru-taxi 题意: 问那个taxi到他的时间最短,水题; AC代码: #include <iostream> #include <cstdio> #i ...
- codeforces 569B B. Inventory(水题)
题目链接: B. Inventory time limit per test 1 second memory limit per test 256 megabytes input standard i ...
- Codeforces 489A SwapSort (水题)
A. SwapSort time limit per test 1 second memory limit per test 256 megabytes input standard input ou ...
- codeforces 688A A. Opponents(水题)
题目链接: A. Opponents time limit per test 1 second memory limit per test 256 megabytes input standard i ...
- CodeForces 534B Covered Path (水题)
题意:给定两个速度,一个一初速度,一个末速度,然后给定 t 秒时间,还每秒速度最多变化多少,让你求最长距离. 析:其实这个题很水的,看一遍就知道怎么做了,很明显就是先从末速度开始算起,然后倒着推. 代 ...
- Codeforces Gym 100286I iSharp 水题
Problem I. iSharpTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hust.edu.cn/vjudge/contest/ ...
- CodeForces 705A(训练水题)
题目链接:http://codeforces.com/problemset/problem/705/A 从第三个输出中可看出规律, I hate that I love that I hate it ...
随机推荐
- jquery serializeArray() 方法通过序列化表单值来创建对象数组(名称和值)。
serializeArray() 方法序列化表单元素(类似 .serialize() 方法),返回 JSON 数据结构数据. html代码: <form> <div><i ...
- C. The Two Routes---cf602C(Dij)
http://codeforces.com/problemset/problem/602/C 题目大意: 有n个城市 有m条铁路 如果两个城市没有铁路 那么一定有公路 求从1 到 n 用铁路和公 ...
- 2017多校Round5(hdu6085~hdu6095)
补题进度:7/11 1001(模意义下的卷积) 题意: 给出长度<=50000的两个数组A[] B[],保证数组中的值<=50000且A[]中数字两两不同,B[]中数字两两不同 有5000 ...
- Java面试题总结之OOA/D,UML,和XML
全文字数: 2732 阅读时间: 大约9 分钟 1.UML 是什么?常用的几种UML图? 统一建模语言(Unified Modeling Language,UML)又称标准建模语言:常用图包括 ...
- SHELL脚本实现分区
写一个脚本(前提:请为虚拟机新增一块硬盘,架设它为/dev/sdb),为指定的硬盘创建分区 1,列出当前系统上所有的磁盘,让用户选择,如果选择quit则退出脚本:如果用户选择错误,就让用户重新选择 2 ...
- Spring错误异常重试框架guava-retrying
官网:https://github.com/rholder/guava-retrying Maven:https://mvnrepository.com/artifact/com.github.rho ...
- Spring的@Qualifier注解
以下内容引用自http://wiki.jikexueyuan.com/project/spring/annotation-based-configuration/spring-qualifier-an ...
- nexus3.1私服搭建
原文:http://blog.csdn.net/qqqqq210/article/details/52993337 1.简介 近期公司需要搭建jenkins自动化构建部署,需要搭建nexus私服环境, ...
- zoom to raster resolution
don't execute the ESRI's command, just find out and write codes to zoom to the raster resolution. H ...
- Docker+Drone做Java/Tomcat的CI服务
1. 安装Docker(略过) 2. 编写docker-compose.yaml version: '2' services: drone-server: image: drone/drone:0.8 ...