#abc279g. G - At Most 2 Colors
G - At Most 2 Colors
Score : points
问题陈述
有一个 的网格,从左到右编号为 。
高桥准备了 种颜色的颜料,并用这 种颜色中的任意一种给每个小方格涂色。
然后,在任意连续的 个小方格中,最多有两种颜色。
形式化地讲,对于满足 的所有整数 ,在第 个小方格中最多有两种颜色。
高桥有多少种不同的涂色方式?
由于这个数字可能非常大,请计算它对 取模的结果。
以上为通义千问 qwen-max 翻译,仅供参考。
Problem Statement
There is a grid with squares, numbered from left to right.
Takahashi prepared paints of colors and painted each square in one of the colors.
Then, there were at most two colors in any consecutive squares.
Formally, for every integer such that , there were at most two colors in squares .
In how many ways could Takahashi paint the squares?
Since this number can be enormous, find it modulo .
Constraints
- All values in the input are integers.
Input
The input is given from Standard Input in the following format:
Output
Print the answer as an integer.
Sample Input 1
3 3 3
Sample Output 1
21
In this input, we have a grid.
Among the ways to paint the squares, there are ways to paint all squares in different colors, and the remaining ways are such that there are at most two colors in any consecutive three squares.
Sample Input 2
10 5 2
Sample Output 2
1024
Since , no matter how the squares are painted, there are at most two colors in any consecutive squares.
Sample Input 3
998 244 353
Sample Output 3
952364159
Print the number modulo .
update @ 2024/3/10 11:45:24