CodeForces 735 A.Ostap and Grasshopper(水~)
来源:互联网 发布:c语言语言 编辑:程序博客网 时间:2024/05/21 17:56
Description
给出一个长度为n的字符串,起点在G,每次只能跳k步,问是否可以调到T点处,#为障碍,.为空地
Input
第一行两个整数n和k表示字符串长度和每次可以跳的距离,之后一个长度为n的字符串(2<=n<=100,1<=k<=n-1)
Output
可以跳到则输出YES,否则输出NO
Sample Input
5 2
#G#T#
Sample Output
YES
Solution
水题,一步步跳
Code
#include<cstdio>#include<iostream>#include<cstring>#include<algorithm>#include<cmath>#include<vector>#include<queue>#include<map>#include<set>#include<ctime>using namespace std;typedef long long ll;#define INF 0x3f3f3f3f#define maxn 111int n,k;char s[maxn];int main(){ while(~scanf("%d%d",&n,&k)) { scanf("%s",s); int g,t; for(int i=0;i<n;i++) { if(s[i]=='G')g=i; if(s[i]=='T')t=i; } if(g>t)swap(g,t); int gg=0; for(int i=g;;i+=k) { if(i>=n||s[i]=='#') { gg=1; break; } if(i==t)break; } printf("%s\n",gg?"NO":"YES"); } return 0;}
0 0
- CodeForces 735 A.Ostap and Grasshopper(水~)
- 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
- Codeforces Round #382 (Div. 2) 735A - Ostap and Grasshopper
- codeforces 735 A. Ostap and Grasshopper (简单题)
- Codeforces Round #382 (Div. 2) 735A Ostap and Grasshopper
- A. Ostap and Grasshopper
- Codeforces Round #382 (Div. 2)-735A. Ostap and Grasshopper(BFS)
- 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
- Codeforces735A Ostap and Grasshopper
- Ostap and Grasshopper
- CodeForces 641 A.Little Artem and Grasshopper(水~)
- CodeForces 733 A.Grasshopper And the String(水~)
- 用EasyX图形库VS2012的控制台的二维图形的绘制(仅限C++)
- java集合系列13 Set
- UGUI画布(Canvas)组件参数踩坑
- python 多线程
- mysql 创建索引
- CodeForces 735 A.Ostap and Grasshopper(水~)
- FMDB基础(oc操作sqlite)
- ARM基础学习-协处理器CP15
- stm32 不断的重新启动的原因
- vs2010--fatal error LNK1112: 模块计算机类型“X86”与目标计算机类型“x64”冲突——我的解决方案
- 【HDU】1512 Monkey King 左偏树
- Singleton模式
- Vue.js 实战总结
- 【bzoj4300】绝世好题