Problem Statement | |||||||||||||
Consider strings constructed from the letters 'A', 'B', and 'C'. You will be given an integer N and two forbidden substrings, bad1 and bad2. You are to calculate the number of strings of length N that do not contain either substring. Note that a substring need not be shorter than the string in which it is contained (e.g., "AB" is a substring of "AB"). | |||||||||||||
Definition | |||||||||||||
| |||||||||||||
Constraints | |||||||||||||
- | N is between 1 and 39, inclusive. | ||||||||||||
- | bad1 contains between 1 and 39 characters, inclusive. | ||||||||||||
- | bad2 contains between 1 and 39 characters, inclusive. | ||||||||||||
- | Each character in bad1 is 'A', 'B', or 'C'. | ||||||||||||
- | Each character in bad2 is 'A', 'B', or 'C'. | ||||||||||||
Examples | |||||||||||||
0) | |||||||||||||
| |||||||||||||
1) | |||||||||||||
| |||||||||||||
2) | |||||||||||||
| |||||||||||||
3) | |||||||||||||
|