SnowflakeOA #7
Coloring Houses
Estimated MediumJudge-ready
Topics (AI-labelled)Bits & MathDP Basics
An even number n of houses stand in a row and are painted with three fixed colors. Any two adjacent houses, and any two houses at the same distance from the two ends, must have different colors. The same color in the catalog is an error. Output the answer modulo 10⁹+7.
Input
One line with an even n in 2..100000.
Output
Output the single integer required by the problem.
Example 1
Input:
2
Output:
6
Example 2
Input:
4
Output:
18
Example 3
Input:
6
Output:
54
Example notes
The answers to the three public examples are, in order: 6; 18; 54. All examples have been verified by independent small-scale enumeration or state search.
Editorial
Loading solution…