CodeForces 526A-King of Thieves

「爱情、让人受尽委屈。」 2022-08-21 04:42 105阅读 0赞

A. King of Thieves

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.

cf24db0205a4ef74e7d39e2a642bcbc8c2afb8a6.png

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 < … < i**k, if i2 - i1 = i3 - i2 = … = i**k - i**k - 1. Of course, all segments i1, i2, … i**k should 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).

Examples

Input

  1. 16
  2. .**.*..*.***.**.

Output

  1. yes

Input

  1. 11
  2. .*.*...*.*.

Output

  1. no

Note

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

解题思路:

我们只需要跳四步,选取五个墩,且距离相同。

  1. #include<stdio.h>
  2. #include<string.h>
  3. #include<algorithm>
  4. using namespace std;
  5. char map[10000];
  6. int main()
  7. {
  8. int T;
  9. scanf("%d",&T);
  10. scanf("%s",map);
  11. int i,j=1;
  12. bool b=false;
  13. while((T/4)>=j)
  14. {
  15. for(i=0;i<T;i++)
  16. {
  17. if(map[i]=='*'&&map[i+j]=='*'&&map[i+2*j]=='*'&&map[i+3*j]=='*'&&map[i+4*j]=='*')//4步5个墩
  18. {
  19. b=1;
  20. break;
  21. }
  22. }
  23. j++;
  24. if(b)
  25. break;
  26. }
  27. if(b)
  28. printf("yes\n");
  29. else
  30. printf("no\n");
  31. return 0;
  32. }

发表评论

表情:
评论列表 (有 0 条评论,105人围观)

还没有评论,来说两句吧...

相关阅读

    相关 526. 优美的排列

    > 假设有从 1 到 N 的 N 个整数,如果从这 N 个数字中成功构造出一个数组,使得数组的第 i 位 (1 <= i <= N) 满足如下两个条件中的一个,我们就称这个数组