旗帜问题的排布
Flag
Time Limit: 1000MS Memory limit: 65536K
题目描述
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:
1. Stripes of the same color cannot be placed next to each other.
2. 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:
输入
N, the number of the stripes, 1 ≤ N ≤ 45.
输出
M, the number of the ways to decorate the shop-window.
示例输入
3
示例输出
4
一开始做的时候,并没有考虑大数据,以促使才知道竟然溢出了,想到用long long int,但还是不行,最后没想到用double就搞定了。注意一下输出即可 printf("%.0lf", f[n]);

浙公网安备 33010602011771号