ural 1225 Flags
来源:互联网 发布:淘宝游戏专营何时开通 编辑:程序博客网 时间:2024/06/05 19:10
1225. Flags
Time limit: 1.0 second
Memory limit: 64 MB
Memory limit: 64 MB
On the Day of the Flag of Russia a shop-owner decided to decorate the show-window of his shop with textile stripes of white, blue and red colors. He wants to satisfy the following conditions:
- Stripes of the same color cannot be placed next to each other.
- A blue stripe must always be placed between a white and a red or between a red and a white one.
Determine the number of the ways to fulfill his wish.
Example. For N = 3 result is following:
Input
N, the number of the stripes, 1 ≤ N ≤ 45.
Output
M, the number of the ways to decorate the shop-window.
Sample
3
4
Problem Source: 2002-2003 ACM Central Region of Russia Quarterfinal Programming Contest, Rybinsk, October 2002
Tags: dynamic programming )
#include <algorithm>#include <map>#include <cstring>#include <cmath>#include <iostream>using namespace std;#define lson l , m , rt << 1#define rson m + 1 , r , rt << 1 | 1#define LL __int64typedef long long ll;#define PI 3.1415926ll dp[46];int main(){ int i; dp[1]=2; dp[2]=2; dp[3]=4; for(i=4;i<=45;i++) dp[i]=dp[i-1]+dp[i-2]; int n; while(cin>>n) cout<<dp[n]<<endl; return 0;}
0 0
- ural 1225 Flags
- Ural 1225 Flags
- URAL-1225 Flags
- Ural 1225 Flags(DP)
- URAL 1225Flags dp练习
- URAL 1225(Flags)简单递推
- URAL 1225 Flags (DP动态规划)
- URAL 1225-Flags(规律递推)
- ural 1225. Flags
- Ural 1225. Flags DP
- URAL 1225. Flags
- 1225. Flags URAL 解题报告
- ural 1225.Flags(简单dp)
- URAL 1225. Flags (dp)
- ural 1692 Flags for Provinces 解题报告
- flags ()
- Flags
- Flags
- springmvc整合shiro
- 恶意代码分析实战(7-01实验学习笔记)
- poj2777 Count Color
- linux下安装python2.7.9最新攻略
- HDU 1754I Hate It 线段树点修改问题
- ural 1225 Flags
- AC自动机算法小结
- 用CocoaPods做ios的依赖管理
- 计算字体所占大小
- (3872)ZOJ
- 输入一个整数和一棵二元树。求出从根节点到叶节点的路径长度中与输入整数相等的所有路径。
- 内存管理arc,mrc
- 关于“==” 和equals()方法以及String类的一写总结
- centos_7.0 1503 配置笔记(二)--设置时间同步