Codeforces Round #438 (Div. 1 + Div. 2 combined) B. Race Against Time(模拟)
来源:互联网 发布:python re.match 编辑:程序博客网 时间:2024/06/04 19:24
题解:
还比较有意思的一题,就是给出时分秒,给出人要走的两个时间点(任何一个都可以作为起点和终点,可以顺时针也可以逆时针),问是否可以顺利走完(不碰到时分秒的针)
思路:
我开了120的数组,每2位表示一个刻度(为了处理不是整点的问题),如果分秒都为0,则时针的位置为h*10,否则随便加一个1-9的数字表示不是整点,同理如果秒为0,分针的位置为m*2,否则就为m*2+1,秒针就直接s*2,然后顺时针搞一遍,可以就输出yes,不行就逆时针搞一遍,可以就输出yes,否则就是no
暂时ac代码:
#include<iostream>#include<cstring>#include<stdio.h>#include<math.h>#include<string>#include<stdio.h>#include<queue>#include<stack>#include<map>#include<vector>#include<deque>#include<algorithm>#define ll long long#define INF 1008611111#define M (t[k].l+t[k].r)/2#define lson k*2#define rson k*2+1using namespace std;int vis[125];int main(){ int t1,t2,h,m,s,tag=1,st,ed,i; scanf("%d%d%d%d%d",&h,&m,&s,&t1,&t2); memset(vis,0,sizeof(vis)); if(h==12) h=0; if(m==0&&s==0) vis[h*10]=1; else vis[h*10+5]=1; if(s==0) vis[m*2]=1; else vis[m*2+1]=1; vis[s*2]=1; if(t1>t2) swap(t1,t2); st=t1*10; ed=t2*10; for(i=st;i<=ed;i++) { if(vis[i]) { tag=0; break; } } if(tag) { printf("YES\n"); return 0; } int flag=1; for(i=ed;i<=120;i++) { if(vis[i]) { flag=0; break; } } for(i=0;i<=st;i++) { if(vis[i]) { flag=0; break; } } if(flag) printf("YES\n"); else printf("NO\n"); return 0;}
阅读全文
0 0
- Codeforces Round #438 (Div. 1 + Div. 2 combined) B. Race Against Time(模拟)
- Codeforces Round #438 (Div. 1 + Div. 2 combined) B. Race Against Time
- Codeforces Round #438 B Race Against Time(模拟)
- Codeforces Round #438 B. Race Against Time
- CodeFroces Round 438 B.Race Against Time(模拟)
- Codeforces Round #438 (Div. 1 + Div. 2 combined) A. Bark to Unlock(模拟)
- Codeforces Round #438 (868B) B Race Against Time
- Codeforces 868B. Race Against Time 模拟
- 【Codeforces 868 B. Race Against Time】& 模拟
- Codeforces Round #438 B. Race Against Time 思路很重要
- Codeforces Round #438 B. Race Against Time 题解
- Wunder Fund Round 2016 (Div. 1 + Div. 2 combined)-B. Guess the Permutation(模拟)
- Codeforces Round #438 (Div. 1 + Div. 2 combined) ABCDF
- Codeforces Round #438 (Div. 1 + Div. 2 combined)
- Codeforces Round #438 (Div. 1 + Div. 2 combined) 总结
- Intel Code Challenge Final Round (Div. 1 + Div. 2, Combined) B(模拟) && codeforce 724B Batch Sort
- Codeforces Round #438 (Div. 1 + Div. 2 combined)(除G)解题报告
- Codeforces Round #400 (Div. 1 + Div. 2, combined)A. A Serial Killer【模拟】
- 机器学习:Naive Bayes中的Bayes公式
- Add Digits:逐位求和直至只剩一位
- Zkw线段树-介绍及各种常用操作
- 拓展lucas [HZOI 2016]艾米利亚的魔法
- Java三大特点
- Codeforces Round #438 (Div. 1 + Div. 2 combined) B. Race Against Time(模拟)
- 实验二 线性表综合实验(循环链表)
- JavaScript高级程序设计——知识点整理(Part 2)
- Milking Grid POJ
- Python列表推导式求素数
- unity3d学习——问题遗留(未解决)
- [Tyvj P4876]近似排列计数[50]
- 相邻两数最大差值 -- 算法小结
- 智能家居成功接入互联网,实现远程访问