hdu1502 Regular Words--DP&大数问题
来源:互联网 发布:iphone 手机铃声软件 编辑:程序博客网 时间:2024/06/15 09:54
原题链接: http://acm.hdu.edu.cn/showproblem.php?pid=1502
一:原题内容
Problem Description
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.
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.
Input
There are mutiple cases in the input file.
Each case contains n (0 <= n <= 60 ).
There is an empty line after each case.
Each case contains n (0 <= n <= 60 ).
There is an empty line after each case.
Output
Output the number of regular words of length 3n .
There should be am empty line after each case.
There should be am empty line after each case.
Sample Input
23
Sample Output
542
二:分析理解
http://www.tuicool.com/articles/ENVn6z 和 http://blog.csdn.net/jiang199235jiangjj/article/details/7452389
三:AC代码
1 0
- hdu1502 Regular Words--DP&大数问题
- HDU1502:Regular Words(大数DP)
- hdu1502 Regular Words(树型dp+大数)
- HDU1502 Regular Words(DP+大数模拟)
- hdu1502 Regular Words 【dp+java】
- [练习][HDU1502]DP Regular Words
- hdu1502 Regular Words 【dp+高精度加法】
- hdu1502 大数dp
- HDU 1502 Regular Words(大数+dp)
- hdu 1502 Regular Words(java大数加法+dp)
- hdu1502 Regular Words 动态规划 高精度 打表
- 【DP】HDU-1502 Regular Words
- Hdu 1502 Regular Words (java高精度 + DP)
- HDU 1502 Regular Words(DP + JAVA)
- HDU 1502 Regular Words 打表+大数相加 .
- hdu 1502 Regular Words DP + 高精度 第一个java
- HDU 1502 Regular Words(打表预处理dp)
- hdu1502
- 证券基础概念(整理自网上)
- PHP面试 第三弹
- 快速转置矩阵
- APK反编译
- yum只下载不安装包
- hdu1502 Regular Words--DP&大数问题
- 基于UDP的Linux畅聊系统(ncurse库和json库)
- 大学毕业4年-回顾和总结(5)-投资理财方法论
- base64编码长度计算
- 第五周项目4——长方柱类
- C# 图片等比例不丢真缩放
- 面包屑 CSS(合并小图标,减少链接请求数量)
- Eclipse新建android项目时候,默认布局方式是RelativeLayout,修改为默认布局方式为LinearLayout
- POJ 1328(Radar Installation 区间贪心)