![](https://img-blog.csdnimg.cn/20201014180756738.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
递推
noon/moon
这个作者很懒,什么都没留下…
展开
-
HDU 2084 数塔
从上向下累加最优子结构 #include <bits/stdc++.h> using namespace std; int main(){ int c;cin>>c; while(c--){ int n;cin>>n; int a[n+1][n+1]={0}; for(int i=1;i<=n...原创 2019-11-06 23:55:56 · 80 阅读 · 0 评论 -
HDU 2085 核反应堆
#include <bits/stdc++.h> using namespace std; typedef long long ll; int main(){ ll n,high[35]={1},low[35]={0}; for(int i=1;i<=33;i++){ high[i]=3*high[i-1]+2*low[i-1]; ...原创 2019-11-03 22:52:04 · 136 阅读 · 0 评论 -
HDU 2049 不容易系列之(4)——考新郎
1.先从n个新郎中选出m个,即Cnm 2.再算出m个新郎的错排数,即f(m) 组合的递推公式以及错排公式的推导参考Hdu 2049解题报告 这里我将组合的求法由递归改为了递推 #include <bits/stdc++.h> using namespace std; typedef long long ll; ll c[25][25],f[25]={0,0,1}; void Init(...原创 2019-10-27 22:18:51 · 147 阅读 · 0 评论 -
HDU 2047 阿牛的EOF牛肉串
参考博客:HDU2047——上进小青年 第n位字符分两种情况: E、F:第n-1位的字符无限制,共有f(n-1)*2种情况 O:第n-1位的字符只能为E、F,共有f(n-2)*2种情况 #include <bits/stdc++.h> using namespace std; typedef long long ll; int main(){ ll n,dp[40]={0,3,...原创 2019-10-24 22:36:22 · 120 阅读 · 0 评论 -
HDU 2046 骨牌铺方格
这篇博客解题思路很明了:HDU 2046 骨牌铺方格(简单递推) 直接以最后一块骨牌分情况: 骨牌竖放:共有f(n-1)种情况 骨牌横置:共有f(n-2)种情况 所以可得:f(n)=f(n-1)+f(n-2)(这不是斐波那契数列吗?) #include <bits/stdc++.h> using namespace std; typedef long long ll; int main...原创 2019-10-24 22:01:51 · 309 阅读 · 0 评论 -
HDU 2045 不容易系列之(3)—— LELE的RPG难题
这篇博客讲得比较好: RPG难题—HDU2045(解题报告) #include <bits/stdc++.h> using namespace std; typedef long long ll; int main(){ ll n,dp[51]={0,3,6,6}; for(int i=4;i<=50;i++) dp[i]=dp[i-1]+dp[i...原创 2019-10-24 21:42:28 · 169 阅读 · 0 评论 -
HDU 2044 一只小蜜蜂...
用long long #include <bits/stdc++.h> using namespace std; typedef long long ll; int main(){ ll dp[50]={0,1,1,2}; for(ll i=4;i<50;i++) dp[i]=dp[i-1]+dp[i-2]; ll n;cin>>...原创 2019-10-24 20:40:23 · 65 阅读 · 0 评论