hdu 5459】的更多相关文章

题目链接: Hdu 5459 Jesus Is Here 题目描述: s1 = 'c', s2 = 'ff', s3 = s1 + s2; 问sn里面所有的字符c的距离是多少? 解题思路: 直觉告诉我们,sn肯定由sn-1与sn-2推导出来的.然后呢,我们可以看出 n%2==1 的时候 sn-1 与 sn-2 由 ffff 衔接起来的,n%2==0 的时候,sn-1 与 sn-2由 ff 衔接起来的.告诉队友后,队友就把这个当成重要依据推啊,推啊!!到最后感觉丢队友自己看药丸,放弃02回来和队友…
Jesus Is Here Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=5459 Description I've sent Fang Fang around 201314 text messages in almost 5 years. Why can't she make sense of what I mean?``But Jesus is here!" the…
http://acm.hdu.edu.cn/showproblem.php?pid=5459 题意: S(1) = c,S(2) = ff, S(3) = cff,之后S(i) = S(i-1)+S(i-2). 现在给出n,求S(n)中任意两个c之间距离的总和. 思路:现在假设第i-1和第i-2要合成第i个,计算S(i)的过程如下: ans[i] = ans[i-1]+ans[i-2]+add,现在要求就是add新增的部分值. 假设S(i-2)中有2个c,下标分别为{a,b}(下标以1为起始点计…
题目;http://acm.hdu.edu.cn/showproblem.php?pid=5459 题意 给出一组字符串,每个字符串都是前两个字符串相加而成,求第n个字符串的c的各个坐标的差的和,结果要模530600414. 很容易看出字符串的长度及c的个数都是由斐波那契数列构成的,得到最后结果是ans[i]=ans[i-1]+ans[i-2]+x,要求的就是x 假设第n项中字符'c'的个数为cn,字符'c'坐标之和为sn,字符串长度为ln 当形成第i个字符串的时候对于第i-1个字符串来说,这个…
Jesus Is Here Time Limit: 1500/1000 MS (Java/Others)    Memory Limit: 65535/102400 K (Java/Others)Total Submission(s): 512    Accepted Submission(s): 368 Problem Description I've sent Fang Fang around 201314 text messages in almost 5 years. Why can't…
Time Limit: 1500/1000 MS (Java/Others)    Memory Limit: 65535/102400 K (Java/Others)Total Submission(s): 250    Accepted Submission(s): 169 Problem Description I've sent Fang Fang around 201314 text messages in almost 5 years. Why can't she make sens…
大意: 定义$f_1="c",f_2="ff",f_n=f_{n-2}+f_{n-1}$, 求所有"cff"的间距和. 记录c的个数, 总长度, 所有c到左边界距离和, 右边界距离和, 所有c的间距. #include <iostream> #include <iostream> #include <algorithm> #include <cstdio> #include <math.h&g…
Sample Input 9 5 6 7 8 113 1205 199312 199401 201314 Sample Output Case #1: 5 Case #2: 16 Case #3: 88 Case #4: 352 Case #5: 318505405 Case #6: 391786781 Case #7: 133875314 Case #8: 83347132 Case #9: 16520782 题目要求当前字符串序列中某项里cff前缀两两间差值的和. 假设已经纪录了cff前缀的…
有点麻烦的递推,递推的原则:向小的问题方向分解,注意边界. 字符串的递推式为 定义f为Si中的总方案数 首先可以得到 fi=fi-1+fi-2+组合(si-2,si-1) 然后考虑Si-2和Si-1之间的组合 为了得到小的问题,进行拆分 为了以后表示的方便和逻辑上的清晰,把Si~Si之间的组合总长度定义出来 因为这里的si-2和si-2的中间还有一段Si-3 所以其组合总长度就可以表示为 Ci表示Si中cff出现的次数,Li表示Si的长度 定义一个函数ccl 最后还剩下一个部分Si-2和Si-3…
Problem Description I've sent Fang Fang around 201314 text messages in almost 5 years. Why can't she make sense of what I mean?``But Jesus is here!" the priest intoned. ``Show me your messages."Fine, the first message is s1=‘‘c" and the sec…