Starry Nights

View as PDF

Points: 17 (partial)
Time limit: 1.0s
Memory limit: 16M

Authors:
Problem type
Allowed languages
Ada, Assembly, Awk, Brain****, C, C#, C++, COBOL, CommonLisp, D, Dart, F#, Forth, Fortran, Go, Groovy, Haskell, Intercal, Java, JS, Kotlin, Lisp, Lua, Nim, ObjC, OCaml, Octave, Pascal, Perl, PHP, Pike, Prolog, Python, Racket, Ruby, Rust, Scala, Scheme, Sed, Swift, TCL, Text, Turing, VB, Zig

ButaneBot is a talented artist, and he spends most of his time painting. When he was still human Butane was not very knowledgeable in art, and only programmed himself to be able to paint ~ characters and * characters. After many trials and experiments, ButaneBot found that the most beautiful paintings he made using these two characters were those of starry nights, and so now he only paints starry nights. A painting is a starry night if it contains at least one star and all its * characters are used for stars.

A star is a pattern that looks exactly like this:

~*~
***
~~~

To be more specific, if a star has its top * at row and column , there should also be * characters at , , and . Furthermore, stars may not share * characters, that is, they CANNOT OVERLAP.

Invalid paintings are show below:

~~~*~
~~***
~***~
~~~~~

~~*~~
~***~
~~~~~
~~~~~
~***~
~~*~~

~~*~~
~***~
~~~~~
~~~~*
~~~~~

For the first painting, there are 2 overlapping stars, or rather 3 extra * characters whichever way you look at it. The second painting includes an upside down star pattern, which is not valid. The third painting has a rogue * character not used for stars.

Given the dimensions of the canvas ButaneBot would like to paint his starry night on, find how many unique ways Butane can make his starry night painting. Since this number may be very large, output the number modulo .

Input Specification

The first and only line of input will contain 2 integers and , the height and width of the canvas.

Constraints

For all test cases, ,

Output Specification

Output one integer, the number of ways ButaneBot can paint a starry night on a canvas of size by .

Sample Input

2 6

Sample Output

5

Explanation for Sample Output

The 5 possible paintings are shown below:

~*~~~~        ~~*~~~        ~~~*~~        ~~~~*~        ~*~~*~
***~~~        ~***~~        ~~***~        ~~~***        ******

• commented on April 2, 2016, 4:03 p.m.

This comment is hidden due to too much negative feedback. Click here to view it.

• commented on April 2, 2016, 4:48 p.m.

fixed

• commented on Dec. 29, 2015, 12:21 p.m.

Would LLSLLLL LSSSSLL LLLSSSL be considered a starry night? (L's are the tildes and S's are the asterisks)

• commented on Dec. 29, 2015, 5:17 p.m.
~~*~~~~
~****~~
~~~***~

Yes, because the stars don't overlap each other.

• commented on Dec. 29, 2015, 5:16 p.m. edited

Edited for clarity.

~~*~~~~
~****~~
~~~***~
• commented on Dec. 28, 2015, 1:03 p.m.

Noticing that it doesn't satisfy the constraints.

• commented on Dec. 28, 2015, 2:25 p.m. edited

Woah nice observation

Updated 3 <= R to 2 <= R, although for the test data it doesn't change anything