您的位置:首页 > 其它

A. King of Thieves

2016-01-28 17:50 176 查看
time limit per test
1 second

memory limit per test
256 megabytes

input
standard input

output
standard output

In this problem you will meet the simplified model of game King of Thieves.

In a new ZeptoLab game called "King of Thieves" your aim is to reach a chest with gold by controlling your character, avoiding traps and obstacles on your way.



An interesting feature of the game is that you can design your own levels that will be available to other players. Let's consider the following simple design of a level.

A dungeon consists of n segments located at a same vertical level, each segment is either a platform that character can stand on, or
a pit with a trap that makes player lose if he falls into it. All segments have the same length, platforms on the scheme of the level are represented as '*' and
pits are represented as '.'.

One of things that affects speedrun characteristics of the level is a possibility to perform a series of consecutive jumps of the same length. More formally, when the character is on the platform number i1,
he can make a sequence of jumps through the platforms i1 < i2 < ... < ik,
if i2 - i1 = i3 - i2 = ... = ik - ik - 1.
Of course, all segments i1, i2, ... ikshould
be exactly the platforms, not pits.

Let's call a level to be good if you can perform a sequence of four jumps of the same length or in the other words there must be
a sequence i1, i2, ..., i5,
consisting of five platforms so that the intervals between consecutive platforms are of the same length. Given the scheme of the level, check if it is good.

Input

The first line contains integer n (1 ≤ n ≤ 100)
— the number of segments on the level.

Next line contains the scheme of the level represented as a string of n characters '*' and '.'.

Output

If the level is good, print the word "yes" (without the quotes), otherwise print the word "no" (without
the quotes).

Sample test(s)

input
16
.**.*..*.***.**.


output
yes


input
11
.*.*...*.*.


output
no


Note

In the first sample test you may perform a sequence of jumps through platforms 2, 5, 8, 11, 14.

解题说明:此题要求在一个字符串中找到五个“*”,它们之间的间隔相等,可以用暴力枚举来做。

#include<cstdio>
#include <cstring>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;

int main()
{
int c, i, j, k, n;
char s[1000];
scanf("%d %s", &n, s);
for(i=1;i<n;i++)
{
for(j=0;j<n;j++)
{
c=0;
for(k=j;k<n;k+=i)
{
if(s[k]=='*')
{
c++;
}
else
{
break;
}
if(c==5)
{
goto end;
}
}
}
}
end:
if(c==5)
{
printf("yes\n");
}
else
{
printf("no\n");
}
return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: