JUMPING RAY!

Ray created a jumping machine which able to (of course) jump with a fix distance. For example, consider the following river layout of 1..10 ('*' means foothold, '.' means water). Need not to say that his machine is not waterproof, so it should not jump into the water.
 Y * . * * * * . . . .
 0 1 2 3 4 5 6 7 8 9 10
If he configures his machine to jump at distance of 3, then he will surely fall at point 9.

IN

3
*.****....
.....
*****

OUT

Case #1: 6
Case #2: 6
Case #3: 1

IN

5
*.****....
.....
*****
*.****..*..
.*.*.*.*..

OUT

Case #1: 6
Case #2: 6
Case #3: 1
Case #4: 3
Case #5: 4

IN

2
*.****....
.....

OUT

Case #1: 6
Case #2: 6

IN

4
*.****....
.....
*****
*.****..*..

OUT

Case #1: 6
Case #2: 6
Case #3: 1
Case #4: 3

IN

1
*.****....

OUT

Case #1: 6


Leave a comment

Parsed as Markdown

Login to leave a comment