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

建议使用的浏览器:

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

1502:Regular Words

题目描述
Consider words of length 3n over alphabet {A, B, C} . Denote the number of occurences of A in a word a as A(a) , analogously let the number of occurences of B be denoted as B(a), and the number of occurenced of C as C(a) .

Let us call the word w regular if the following conditions are satisfied:

A(w)=B(w)=C(w) ;
if c is a prefix of w , then A(c)>= B(c) >= C(c) .
For example, if n = 2 there are 5 regular words: AABBCC , AABCBC , ABABCC , ABACBC and ABCABC .

Regular words in some sense generalize regular brackets sequences (if we consider two-letter alphabet and put similar conditions on regular words, they represent regular brackets sequences).

Given n , find the number of regular words.
输入解释
There are mutiple cases in the input file.

Each case contains n (0 <= n <= 60 ).

There is an empty line after each case.
输出解释
Output the number of regular words of length 3n .

There should be am empty line after each case.
输入样例
2

3
输出样例
5

42
来自杭电HDUOJ的附加信息
Recommend xhd

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

源链接: HDU-1502

最后修改于 2020-10-25T22:45:32+00:00 由爬虫自动更新

共提交 79

通过率 86.08%
时间上限 内存上限
2000/1000MS(Java/Others) 65536/32768K(Java/Others)