Here is a PDF version of the problems if it helps you :)
You might have noticed that there is the new fashion among rich people to have their yards tiled with black and white tiles, forming a pattern. The company Broken Tiles is well known as the best tiling company in our region. It provides the widest choices of nice patterns to tile your yard with. The pattern is nice if there is no square of size 2 * 2, such that all tiles in it have the same color. So patterns on the figure 1 are nice, while patterns on the figure 2 are not.
This problem contains multiple test cases!
The first line of a multiple input is an integer T, then a blank line followed by T input blocks. Each input block is in the format indicated in the problem description.
The output format consists of T lines. There is no need to print any blanklines between test cases.
The input file contains three integer numbers: N (1 <= N <= 10100), M (1 <= M <= 5) and P (1 <= P <= 10000).
For each test case, output the number of nice patterns of size N*M modulo P in a single line.
There is no need to print any blank lines between test cases.
2 2 2 5 3 3 23
4 0
Migrated from old NTUJ.
ZOJ 2317
No. | Testdata Range | Score |
---|