Codeforces Round #382 (Div. 2) 735A - Ostap and Grasshopper
2016-11-28 12:30
309 查看
http://codeforces.com/problemset/problem/735/A
题意:
一只蚂蚱在路上蹦,输入路的长度n和蚂蚱每次蹦的距离k,在这条路上,蚂蚱只能落在'.'上,不能落在'#'上,蚂蚱从G开始蹦,若能蹦到T,输出YES,否则NO。
代码:
题意:
一只蚂蚱在路上蹦,输入路的长度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; }
相关文章推荐
- Codeforces Round #382 (Div. 2) A. Ostap and Grasshopper
- Codeforces Round #382 (Div. 2) A. Ostap and Grasshopper
- codeforces - 735A-Ostap and Grasshopper
- Codeforces Round #382 (Div. 2) A. Ostap and Grasshopper bfs
- CodeForces 735A - Ostap and Grasshopper(思维)
- Codeforces Round #382 (Div. 2) A. Ostap and Grasshopper
- codeforces 735 A Ostap and Grasshopper
- Ostap and Grasshopper
- Codeforces Round #378 (Div. 2) A. Grasshopper And the String(水题求跳跃距离)
- Codeforces Round #382 (Div. 2)A到D题 A. Ostap and //B. Urbanization//C. Tennis Championship//D. Taxes
- A. Ostap and Grasshopper
- 735 A. Ostap and Grasshopper codeforces
- Codeforces Round #378 (Div. 2)A.Grasshopper And the String【水题】模拟
- Codeforces Round #382 (Div. 1) C. Ostap and Tree
- Codeforces Round #378 (Div. 2)A. Grasshopper And the String
- CodeForces 735 A.Ostap and Grasshopper(水~)
- 【64.22%】【codefoces round 382A】Ostap and Grasshopper
- Codeforces Round #348 (div 2) B - Little Artem and Grasshopper
- Ostap and Grasshopper
- Codeforces Round #382 (Div. 2) E. Ostap and Tree