当前位置:网站首页>【小码匠自习室】ABC258-A 代码写的啰嗦了
【小码匠自习室】ABC258-A 代码写的啰嗦了
2022-08-08 13:52:00 【小码匠】
碎碎念
- 《论当你在赛后才发现你做的两个判断语句是多么愚蠢这件事》
标签
- 数学
题目地址
A - When?
- https://atcoder.jp/contests/abc258/tasks/abc258_a
問題描述
AtCoder Beginner Contest usually starts at 21:00 JST and lasts for 100 minutes.
You are given an integer K between 00 and 100100 (inclusive). Print the time K minutes after 21:00 in the HH:MM
format, where HH
denotes the hour on the 24-hour clock and MM
denotes the minute. If the hour or the minute has just one digit, append a 0 to the beginning to represent it as a 2-digit integer.
Constraints
- K is an integer between 0 and 100 (inclusive).
Input
Input is given from Standard Input in the following format:
K
Output
Print the time K minutes after 21:00 in the format specified in the Problem Statement.
Sample Input 1
63
Sample Output 1
22:03
6363 minutes after 21:00, it will be 22:03, so 22:03
should be printed.
The following outputs would be judged incorrect:
10:03
22:3
Sample Input 2
45
Sample Output 2
21:45
Sample Input 3
100
Sample Output 3
22:40
题解
小码匠题解
void coder_solution() {
// 提升cin、cout效率
ios::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
int k;
cin >> k;
int h = k / 60;
if (21 + h >= 24) {
if ((21 + h) % 24 < 10) {
cout << 0 << (21 + h) % 24;
} else {
cout << (21 + h) % 24;
}
} else {
cout << 21 + h;
}
cout << ':';
if (k % 60 < 10) {
cout << 0 << k % 60;
} else {
cout << k % 60;
}
}
小码匠题解
void best_solution() {
// 提升cin、cout效率
ios::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
int k;
cin >> k;
int h = k / 60;
cout << 21 + h << ':';
if (k % 60 < 10) {
cout << 0 << k % 60;
} else {
cout << k % 60;
}
}
参考题解(tourist)
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "algo/debug.h"
#else
#define debug(...) 42
#endif
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
int k;
cin >> k;
int h = 21 + k / 60;
int m = k % 60;
cout << h << ":" << m / 10 << m % 10 << '\n';
return 0;
}
参考题解
#include <iostream>
#include <cstdio>
using namespace std;
int main() {
int X;
cin >> X;
int H = X < 60 ? 21 : 22;
int M = X % 60;
printf("%d:%02d", H, M);
return 0;
}
边栏推荐
猜你喜欢
哈佛大学砸场子:DALL-E 2只是「粘合怪」,生成正确率只有22%
HackTheBox | Horizontall
腾讯,投了个 “离诺贝尔奖最近的华人”
【电路基础2】电容
idea中项目呈现树形结构
Harvard University smashes the field: DALL-E 2 is just a "glue monster", and the generation accuracy rate is only 22%
《预训练周刊》第56期:长文本理解、即时问答、掩码自监督
直接选择排序
[Redis] Redis installation and use of client redis-cli (batch operation)
【系统设计】S3 对象存储
随机推荐
textarea disable drag and drop
非科班毕业生,五面阿里:四轮技术面+HR一面已拿offer
论文理解:“Self-adaptive loss balanced Physics-informed neural networks“
[界面开发]DevExpress WinForms流程图控件——XtraDiagrams组件入门指南
什么样的程序员在35岁依然被公司抢着要?打破程序员“中年危机”
南非 KMP 媒体集团实施了 DMS(文档管理系统)使流程数字化,员工可以再次专注于他们的实际任务,提供了效率
Harvard University smashes the field: DALL-E 2 is just a "glue monster", and the generation accuracy rate is only 22%
Photoshop插件-charIDToTypeID-PIStringTerminology.h-不同值的解释及参考-脚本开发-PS插件
Verilog HDL Bits training 09 grammar foundation
R语言ggplot2可视化:使用ggpubr包的ggdonutchart函数可视化甜甜圈图(donut chart)、为甜甜圈图添加自定义标签(包含文本内容以及数值百分比)、lab.font参数设置标
你是什么时候对深度学习失去信心的?
Tensorflow与Keras进行机器学习、深度学习
idea增加左右箭头
SAP数据迁移需要多久?
使用.NET简单实现一个Redis的高性能克隆版(三)
使用shardingjdbc实现读写分离配置
MapStruct入门使用
代码随想录笔记_动态规划_322零钱兑换
MySQl表的增删查改(CRUD)
HackTheBox | Previse