CodeFroces Round 438 B.Race Against Time(模拟)
来源:互联网 发布:ios与安卓的区别 知乎 编辑:程序博客网 时间:2024/06/10 19:06
题意:给出时间,那么钟上的三个指针就确定位置,现在要从t1到t2,中途不可以穿越指针,问是否可行。
解法:当时想的是既然是小时之间的,那么我只需要把小时之间的给标记了即可。但是这样写会有反例。所以应该把这个钟扩大12*60倍。然后对应的标记上每个指针的位置,然后正反for一遍即可。
代码如下:
#include<iostream>#include<cstdio>#include<vector>#include<queue>#include<utility>#include<stack>#include<algorithm>#include<cstring>#include<string>#include<cmath>#include<set>#include<map>using namespace std;bool flag[60005];int main() {#ifndef ONLINE_JUDGE//freopen("in.txt", "r", stdin);// freopen("out.txt", "w", stdout);#endifint h, m, s, t1, t2;scanf("%d%d%d%d%d", &h, &m, &s, &t1, &t2);if(h == 12)h = 0;if(t1 == 12)t1 = 0;if(t2 == 12)t2 = 0;flag[h * 3600 + m * 60 + s] = 1;flag[m * 60 * 12 + s] = 1;flag[s * 60 * 12] = 1;t1 *= 3600;t2 *= 3600;bool key = 0;if(t1 == t2)key = 1;for(int i = t1; ; i++) {if(i == t2)key = 1;if(flag[i])break;if(i >= 60000)i = -1;}for(int i = t1; ; i--) {if(i == t2)key = 1;if(flag[i]) break;if(i <= 0)i = 60000;}if(key == 1)printf("YES\n");elseprintf("NO\n");return 0;}
阅读全文
0 0
- CodeFroces Round 438 B.Race Against Time(模拟)
- Codeforces Round #438 B Race Against Time(模拟)
- Codeforces Round #438 B. Race Against Time
- Codeforces Round #438 (Div. 1 + Div. 2 combined) B. Race Against Time(模拟)
- Codeforces Round #438 (868B) B Race Against Time
- Codeforces Round #438 B. Race Against Time 思路很重要
- Codeforces Round #438 B. Race Against Time 题解
- CF 868 B. Race Against Time【模拟】
- Codeforces 868B. Race Against Time 模拟
- 【Codeforces 868 B. Race Against Time】& 模拟
- Codeforces868B Race Against Time (模拟)
- Codeforces Round #438 (Div. 1 + Div. 2 combined) B. Race Against Time
- Codeforces 868 B Race Against Time(水题)
- codeforces 868B Race Against Time
- CodeForces 868B Race Against Time
- codeforces 868B Race Against Time
- Codeforces868B Race Against Time
- Codeforce Race Against Time
- java基础-内部类
- Python学习笔记·计算生态(软件开发方法)
- 第四周——项目1
- ubuntu 更换系统源和pip源
- 卸载erlang-使用yum install命令安装
- CodeFroces Round 438 B.Race Against Time(模拟)
- ionic 自定义native插件
- 为什么有了抽象类还要用接口呢?
- Android如何通过手机获取验证码来完成注册功能_Android
- 个人拥有的第一个博客,我是一个菜鸟前端程序员,希望有大神指导
- yum 安装nginx 后 nginx的 目录
- 快速幂
- codeforce_868B_模拟水
- ZigZag Conversion:把字符串改写成Z字排列