hdu1502 Regular Words--DP&大数问题
发布日期:2021-10-03 20:32:05
浏览次数:3
分类:技术文章
本文共 1009 字,大约阅读时间需要 3 分钟。
原题链接:
一:原题内容
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.
Input
There are mutiple cases in the input file. 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.
Sample Input
23
Sample Output
542
二:分析理解
和
三:AC代码
转载地址:https://blog.csdn.net/LaoJiu_/article/details/51001961 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!
发表评论
最新留言
哈哈,博客排版真的漂亮呢~
[***.90.31.176]2024年04月22日 17时35分47秒
关于作者
喝酒易醉,品茶养心,人生如梦,品茶悟道,何以解忧?唯有杜康!
-- 愿君每日到此一游!
推荐文章
C语言,字符串指针做函数参数
2021-06-30
书籍推荐
2021-06-30
Linux内核中的GPIO系统
2021-06-30
uboot和Linux内核移植
2021-06-30
送你一个Git命令地图
2021-06-30
STM32的map文件学习笔记
2021-06-30
我有个队友,叫悟空
2019-04-27
一个大神的Android成长之路
2019-04-27
串口通讯你真的会了吗?不妨看看这些经验
2019-04-27
终于讲透了,史上最详细的RS485串口通讯!
2019-04-27
一些函数、变量命名法及代码规范
2019-04-27
解引用NULL为什么会导致程序挂死?
2019-04-27
那年夏日我吃瓜
2019-04-27
别瞎找了,你要的C语言经典示例都在这~
2019-04-27
如何写出让同事无法维护的代码?
2019-04-27
调试,是一件有挑战的事情
2019-04-27
如何通俗易懂的解释PWM?
2019-04-27
一个前辈总结的思考
2019-04-27
我准备毕业了,怎么规划我的职业生涯?
2019-04-27
危难时刻,每个人都应该站出来
2019-04-27