递推 hdu 1396】的更多相关文章

给你边长为n的等边三角形 算有几个三角形 z[1]=1; 第N层 z[n] 1   n-1层 z[n-1] 2   2*n-1 个小的 3   新产生的 正的>1的三角形 n*(n-1)/2; 4   新产生的倒的>1的三角形  /这边可以去推一推 #include<stdio.h> #include<string.h> #include<algorithm> #include<math.h> using namespace std; typed…
http://blog.csdn.net/wust_xhj/article/details/47779539 怎么推可以看这里 f[0]=0 f[1]=1 [0,1]* | 0  q  |(n-1)=[f(n-1),f(n)]  | 1 q-1| 跑一下快速幂 #include<stdio.h> #include<string.h> #include<algorithm> #include<math.h> using namespace std; typed…
http://www.cnblogs.com/rainydays/archive/2013/01/16/2862235.html 看样例的答案 #include<stdio.h> #include<string.h> #include<algorithm> #include<math.h> using namespace std; typedef long long ll; #define MAXN 100010 double z[MAXN]; int ma…
考虑n-2 n-1 n z[n] 代表n个块 可行方案 1  n-2 和n-1 同 3*z[n-2] 2  n-2和n-1不同 2*(z[n-1]-z[n-2]); 减一减 然后可能是其中一种 *2 z[n]=2*z[n-1]+z[n-2]; z[1]=3; z[2]=9; #include<stdio.h> #include<string.h> #include<algorithm> #include<math.h> using namespace std…
z[n] n个盘子从1到3次数 先想2个的时候  1->2 2->3  1->2 3->2 2->1 2->3 1->2 2->3 显然 要先把上面n-1 先移动到3  然后 1->2  然后 3->1 然后 2->3 然后 1->3 其实就是 在z[n]=3*z[n-1]+2; 如果整理一下 就可以o(1); #include<stdio.h> #include<string.h> #include<a…
t 关于错排 共n个数 第n个 和一个交换  其他n-2错排  (n-1)*z[n-2]; n-1个错排 第n个和n-1个交换    (n-1)*z[n-1]; 求和 然后概率的话要除n! 一个一个除 #include<stdio.h> #include<string.h> #include<algorithm> #include<math.h> using namespace std; #define MAXN 105 double z[MAXN]; in…
n%2==1 0 n%2==0 右边和左边没影响 右边的 * 左边的 z[n]=3*z[n-2]+2*z[n-4]+...2*z[0]; z[n-2]=3*z[n-4]+2*z[n-6]+...2*z[0]; z[n]=4*z[n-2]-z[n-4]; z[0]=1; z[2]=3 #include<stdio.h> #include<string.h> #include<algorithm> #include<math.h> using namespace…
下沙的沙子有几粒? Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 2584    Accepted Submission(s): 1346 Problem Description 2005年11月份,我们学校参加了ACM/ICPC 亚洲赛区成都站的比赛,在这里,我们获得了历史性的突破,尽管只是一枚铜牌,但获奖那一刻的激动,也许将永远铭刻…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2842 题目大意:棒子上套环.第i个环能拿下的条件是:第i-1个环在棒子上,前i-2个环不在棒子上.每个环可以取下或放上,cost=1.求最小cost.MOD 200907. 解题思路: 递推公式 题目意思非常无聊,感觉是YY的. 设$dp[i]$为取第i个环时的总cost. $dp[1]=1$,$dp[2]=2$,前两个环取下是没有条件要求的. 从i=3开始,由于条件对最后的环限制最大,所以从最后一…
不容易系列之一 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 13566    Accepted Submission(s): 5660 Problem Description 大家常常感慨,要做好一件事情真的不容易,确实,失败比成功容易多了!做好“一件”事情尚且不易,若想永远成功而总从不失败,那更是难上加难了,就像花钱总是比挣钱容易的…