ural 1225 Flags
2015-04-27 20:10
686 查看
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:
Problem Source: 2002-2003 ACM Central Region of Russia Quarterfinal Programming Contest, Rybinsk, October 2002
Tags: dynamic programming (
hide tags for unsolved problems
)
题意:蓝色只能在白红之间,不能连续放同一个颜色。问有几种方法
水题,简单DP。
1225. Flags
Time limit: 1.0 secondMemory 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
input | output |
---|---|
3 | 4 |
Tags: dynamic programming (
hide tags for unsolved problems
)
题意:蓝色只能在白红之间,不能连续放同一个颜色。问有几种方法
水题,简单DP。
#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 __int64 typedef long long ll; #define PI 3.1415926 ll 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 <<endl; return 0; }
相关文章推荐
- URAL 1225(Flags)简单递推
- 递推DP URAL 1225 Flags
- URAL1225——DP——Flags
- ural1225-Flags-动态规划
- Ural_Dynamic Programming Problems_1225-Flags
- ural 1225. Flags
- URAL 1225. Flags
- Ural 1225 Flags
- URAL-1225 Flags
- URAL 1225 Flags (DP动态规划)
- URAL 1225 Flags 简单DP,一重循环
- URAL1225 Flags, DP
- ural 1225.Flags
- Ural 1225 Flags(DP)
- Ural_1225 Flags
- ural 1225.Flags(简单dp)
- URAL 1225-Flags(规律递推)
- timus 1225 flags 基础DP 简单递推
- URAL 1225 递推
- URAL 1225 Flags dp练习