当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

6960:Necklace of Beads

题目描述
Beads of red, blue or green colors are connected together into a circular necklace of \(n\) beads. If the repetitions that are produced by rotation around the center of the circular necklace are all neglected, the green beads appear no more than \(k\) times, and all adjacent beads are of different colors, how many different forms of the necklace are there?
输入解释
The first line contains an integer \( T(1\le T\le 10) \)representing the number of test cases.

For each test case, there are two integers \(n,k(3\le n\le 10^6,0\le k\le 10^6) \)in one line.

It is guaranteed that \(\sum n,\sum k < 5*10^6\).
输出解释
For each test case, print a line with an integer, representing the answer, modulo \(998244353\).
输入样例
3
3 1
4 1
10 3
输出样例
2
3
58

该题目是Virtual Judge题目,来自 杭电HDUOJ

源链接: HDU-6960

最后修改于 2021-10-23T19:10:50+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
2000/1000MS(Java/Others) 262144/262144K(Java/Others)