Ural 1260. Nudnik Photographer DP
2013-08-12 09:01
375 查看
1260. Nudnik Photographer
Time limit: 1.0 secondMemory limit: 64 MB
If two people were born one after another with one second difference and one of them is a child, then the other one is a child too. We get by induction that all the people are children.
Everyone knows that the mathematical department of the Ural State University is a big family of Npersons, 1, 2, 3, …, N years old respectively.
Once the dean of the department ordered a photo if his big family. There were to be present all the students of the department arranged in one row. At first the dean wanted to arrange them by their
age starting from the youngest student, but than he decided that it would look unnatural. Than he advised to arrange the students as follows:
The 1 year old student is to sit at the left end of the row.
The difference in ages of every two neighbors mustn’t exceed 2 years.
The dean decided that thereby the students would seem look as they were arranged by their ages (one can hardly see the difference in ages of 25 and 27 years old people). There exist several arrangements
satisfying to the requirements. Photographer didn’t want to thwart dean’s desire and made the photos of all the possible mathematical department students’ arrangements.
Input
There is the integer number N, 1 ≤ N ≤ 55.Output
the number of photos made by the photographer.Sample
input | output |
---|---|
4 | 4 |
Hint
If N = 4 then there are following possible arrangements: (1,2,3,4), (1,2,4,3), (1,3,2,4) and (1,3,4,2).Problem Author: Alexander Ipatov
Problem Source: Open collegiate programming contest for high school children of the Sverdlovsk region, October 11, 2003
动态转移方程:
dp[i]=dp[i-1]+dp[i-3]+1
#include <iostream> #include <cstdio> using namespace std; int dp[60]; int main() { int n,i; dp[1]=dp[2]=1; dp[3]=2; scanf("%d",&n); for(i=4;i<=n;i++) dp[i]=dp[i-1]+dp[i-3]+1; cout<<dp <<endl; return 0; }
相关文章推荐
- 1260. Nudnik Photographer dp
- 递推DP URAL 1260 Nudnik Photographer
- ural 1260. Nudnik Photographer(dp)
- 【URAL 1260】 DP (dfs打表之后找规律也行)
- Ural 1260 A nudnik photographer(DP)
- Ural 1260 A nudnik photographer(DP)
- Ural 1260. A nudnik photographer(dp)
- 【dp 挺棒的】URAL - 1260 Nudnik Photographer
- Ural_1260. Nudnik Photographer(DP)
- poj-1260 -Pearls-DP
- hdoj 1260 Tickets 【简单DP】
- poj 1260 Pearls 斜率优化dp
- Ural 1353 Milliard Vasya's Function(DP)
- ural 1923 Another Ecology Problem(博弈dp)
- hdu 1260 Tickets(DP)
- URAL - 1009 - K-based Numbers (简单DP)
- URAL 2052 . Physical Education (数位DP + 二分)
- poj 1260 Pearls (DP)
- URAL 1009 K-based Numbers dp练习
- HDU-1260 Tickets(DP)