POJ 1953】的更多相关文章

题意:n位长的01序列(0 < n < 45),但不能出现连续的两个1,问序列有多少种. 题目链接:id=1953" target="_blank">http://poj.org/problem? id=1953 -->>设dp[i][j]表示前 i 位中第 i 位为 j 时的序列数.则状态转移方程为: dp[i][0] = dp[i - 1][0] + dp[i - 1][1]; dp[i][1] = dp[i - 1][0]; 由于对于同样的…
//FINBONACI数列 #include <iostream> #define MAXN 100 using namespace std; int _m[MAXN]; int main() { //freopen("acm.acm","r",stdin); int test; int i; int n; ; _m[] = ; _m[] = ; ; i < ; ++ i) { _m[i] = _m[i-] + _m[i-]; } cin>&…
World Cup Noise Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 16369   Accepted: 8095 Description Background "KO-RE-A, KO-RE-A" shout 54.000 happy football fans after their team has reached the semifinals of the FIFA World Cup in t…
用n个数字0或者1组成一个排列,要求每两个1不相邻,问有多少种排法 dp[n][0]记录n个连续数,结尾为0的不同排列数dp[n][1]记录第n个连续数,结尾为1的不同排列数 DP公式: dp[i][0]=dp[i-1][0]+dp[i-1][1];  此数为0,前面是0或1均可dp[i][1]=dp[i-1][0];             此数为1,前面只能是0: #include<iostream> using namespace std; //dp[i][0]记录第i个连续数,结尾为0…
https://vjudge.net/problem/POJ-1953 题意:输入一个n,这n位数只由0和1组成,并且不能两个1相邻.计算共有多少种排列方法. 思路:递推题. 首先a[1]=2,a[2]=3是显而易见的,接下来计算分析到第n位时的排列方法数,如果第n-1位数为1,那么第n位只能为0,那么此时有g[n-1]种方法(g[n-1]表示第n-1位为1的数量).如果第n-1位为0,那么此时有2*f[n-1]种方法(f[n-1]表示第n-1位为0的数量). 所以,两者相加=g[n-1]+2*…
World Cup Noise Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 14397   Accepted: 7129 Description Background "KO-RE-A, KO-RE-A" shout 54.000 happy football fans after their team has reached the semifinals of the FIFA World Cup in t…
World Cup Noise Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 16774   Accepted: 8243 Description Background "KO-RE-A, KO-RE-A" shout 54.000 happy football fans after their team has reached the semifinals of the FIFA World Cup in t…
Log 2016-3-21 网上找的POJ分类,来源已经不清楚了.百度能百度到一大把.贴一份在博客上,鞭策自己刷题,不能偷懒!! 初期: 一.基本算法: (1)枚举. (poj1753,poj2965) (2)贪心(poj1328,poj2109,poj2586) (3)递归和分治法. (4)递推. (5)构造法.(poj3295) (6)模拟法.(poj1068,poj2632,poj1573,poj2993,poj2996) 二.图算法: (1)图的深度优先遍历和广度优先遍历. (2)最短路…
初期:一.基本算法:     (1)枚举. (poj1753,poj2965)     (2)贪心(poj1328,poj2109,poj2586)     (3)递归和分治法.     (4)递推.     (5)构造法.(poj3295)     (6)模拟法.(poj1068,poj2632,poj1573,poj2993,poj2996)二.图算法:     (1)图的深度优先遍历和广度优先遍历.     (2)最短路径算法(dijkstra,bellman-ford,floyd,hea…
初期: 一.基本算法:      (1)枚举. (poj1753,poj2965)      (2)贪心(poj1328,poj2109,poj2586)      (3)递归和分治法.      (4)递推.      (5)构造法.(poj3295)      (6)模拟法.(poj1068,poj2632,poj1573,poj2993,poj2996) 二.图算法:      (1)图的深度优先遍历和广度优先遍历.      (2)最短路径算法(dijkstra,bellman-ford…