zoj 3725 DP排列
2013-07-16 20:05
197 查看
DP计数,
有限制性条件下的计数无法直接推公式,一般含有重复,无法完全吻合
这时选择dp,调用前面算出的结果
有限制性条件下的计数无法直接推公式,一般含有重复,无法完全吻合
这时选择dp,调用前面算出的结果
(two[i-m-1]-dp[i-m-1])用的妙!
#include <iostream> #include <cstdio> #include <cstring> using namespace std; #define ll long long #define mod 1000000007 #define N 100500 ll two ; ll dp ; int main () { ll n,m; two[0]=1; for(int i=1;i<N;++i) two[i]=two[i-1]*2%mod; while(scanf("%lld%lld",&n,&m)!=EOF) { memset(dp,0,sizeof(dp)); dp[m]=1; for(int i=m+1;i<=n;++i) { dp[i]=2*dp[i-1]+(two[i-m-1]-dp[i-m-1]); dp[i]%=mod; } dp =(dp %mod+mod)%mod; printf("%lld\n",dp ); } return 0; }
相关文章推荐
- ZOJ-3725 Painting Storages DP
- ZOJ 3725 Painting Storages DP+排列计数
- [ACM] ZOJ 3725 Painting Storages (DP计数+组合)
- zoj3725 组合数学,递推
- ZOJ 3725 Painting Storages(很好的dp题)
- [ACM] ZOJ 3725 Painting Storages (DP计数+组合)
- ZOJ-3725
- zoj 3725 Painting Storages dp
- zoj 3725 dp求排列组合数
- ZOJ 3725 Painting Storages 解题报告
- ZOJ - 3725 Painting Storages
- ZOJ - 3725 Painting Storages
- zoj 3725 Painting Storages 题解
- ZOJ 3725 Painting Storages(DP解排列计数)
- ZOJ-3725 Painting Storages 动态规划
- zoj 3725
- zoj 3725 Painting Storages
- zoj 3725
- ZOJ 3725 Painting Storages
- ZOJ 3725 - Painting Storages(DP)