Codeforces Round #382 (Div. 2) 735A - Ostap and Grasshopper
来源:互联网 发布:李荣浩后羿知乎 编辑:程序博客网 时间:2024/05/01 03:07
http://codeforces.com/problemset/problem/735/A
题意:
一只蚂蚱在路上蹦,输入路的长度n和蚂蚱每次蹦的距离k,在这条路上,蚂蚱只能落在'.'上,不能落在'#'上,蚂蚱从G开始蹦,若能蹦到T,输出YES,否则NO。
代码:
#include <iostream>#include <cstring>using namespace std;char ch[1000];int flag=0;int n,k;int be,en;int main(){ cin>>n>>k; for(int i=1;i<=n;i++) { cin>>ch[i]; if(ch[i]=='G') be=i; if(ch[i]=='T') en=i; } if(be>en) be^=en^=be^=en; for(int i=be;i<=en;i+=k) { if(i==en) { flag=1; cout<<"YES"<<endl; } else if(ch[i]=='#') { break; } } if(!flag) cout<<"NO"<<endl; return 0;}
0 0
- Codeforces Round #382 (Div. 2) 735A - Ostap and Grasshopper
- Codeforces Round #382 (Div. 2) 735A Ostap and Grasshopper
- Codeforces Round #382 (Div. 2) A. Ostap and Grasshopper
- Codeforces Round #382 (Div. 2) A. Ostap and Grasshopper
- Codeforces Round #382 (Div. 2) A. Ostap and Grasshopper
- Codeforces Round #382 (Div. 2)-735A. Ostap and Grasshopper(BFS)
- CodeForces 735A - Ostap and Grasshopper(思维)
- codeforces - 735A-Ostap and Grasshopper
- 735 A. Ostap and Grasshopper codeforces
- codeforces 735 A Ostap and Grasshopper
- CodeForces 735A Ostap and Grasshopper
- 【64.22%】【codefoces round 382A】Ostap and Grasshopper
- codeforces 735 A. Ostap and Grasshopper (简单题)
- CodeForces 735 A.Ostap and Grasshopper(水~)
- A. Ostap and Grasshopper
- Codeforces Round #378 (Div. 2)A. Grasshopper And the String
- Codeforces Round #378 (Div. 2) A. Grasshopper And the String
- Codeforces Round #382 (Div. 2) E. Ostap and Tree
- POJ No.3617-Best Cow Line(字典序最小问题)
- Java的锁机制
- python 环境搭建(二) pip源的修改
- 【新手】关于进制转换
- codeforces 740A Alyona and copybooks
- Codeforces Round #382 (Div. 2) 735A - Ostap and Grasshopper
- Path Sum II ---LeetCode
- 员工没热情?这8个简单方法比加薪都管用
- spring 之 PropertiesLoaderUtils 获取文件属性用法
- 深度学习的40种应用
- Codeforce 382总结
- Rotate List
- 流氓鲁大师劫持了我的谷歌浏览器
- 汇编中16进制装换成为其他进制(2,8,10)