AtCoder Regular Contest 108
翻译中…
Problem Statement
翻译中…
Given are an integer $N$ and four characters $c_{\mathrm{AA}}$, $c_{\mathrm{AB}}$, $c_{\mathrm{BA}}$, and $c_{\mathrm{BB}}$. Here, it is guaranteed that each of those four characters is A or B.
翻译中…
Snuke has a string $s$, which is initially AB.
翻译中…
Let $|s|$ denote the length of $s$. Snuke can do the four kinds of operations below zero or more times in any order:
翻译中…
- Choose
$i$such that$1 \leq i < |s|$,$s_{i}$=A,$s_{i+1}$=Aand insert$c_{\mathrm{AA}}$between the$i$-th and$(i+1)$-th characters of$s$. - Choose
$i$such that$1 \leq i < |s|$,$s_{i}$=A,$s_{i+1}$=Band insert$c_{\mathrm{AB}}$between the$i$-th and$(i+1)$-th characters of$s$. - Choose
$i$such that$1 \leq i < |s|$,$s_{i}$=B,$s_{i+1}$=Aand insert$c_{\mathrm{BA}}$between the$i$-th and$(i+1)$-th characters of$s$. - Choose
$i$such that$1 \leq i < |s|$,$s_{i}$=B,$s_{i+1}$=Band insert$c_{\mathrm{BB}}$between the$i$-th and$(i+1)$-th characters of$s$.
翻译中…
Find the number, modulo $(10^9+7)$, of strings that can be $s$ when Snuke has done the operations so that the length of $s$ becomes $N$.
翻译中…
Constraints
翻译中…
$2 \leq N \leq 1000$- Each of
$c_{\mathrm{AA}}$,$c_{\mathrm{AB}}$,$c_{\mathrm{BA}}$, and$c_{\mathrm{BB}}$isAorB.
翻译中…
Input
翻译中…
Input is given from Standard Input in the following format:
翻译中…
N
c_{\mathrm{AA}}
c_{\mathrm{AB}}
c_{\mathrm{BA}}
c_{\mathrm{BB}}
翻译中…
Output
翻译中…
Print the number, modulo $(10^9+7)$, of strings that can be $s$ when Snuke has done the operations so that the length of $s$ becomes $N$.
翻译中…
样例
Input #1
4
A
B
B
A
Output #1
2
- There are two strings that can be $s$ when Snuke is done: `ABAB` and `ABBB`.
Input #2
1000
B
B
B
B
Output #2
1
- There is just one string that can be $s$ when Snuke is done.
题目信息
题面与样例版权归 AtCoder 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。