Nudnik Photographer
来源:互联网 发布:数据采集卡安装 编辑:程序博客网 时间:2024/05/16 11:20
1260. Nudnik Photographer
Time limit: 1.0 second
Memory limit: 64 MB
Memory 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
4
4
#include <map>#include <set>#include <list>#include <queue>#include <stack>#include <cmath>#include <ctime>#include <vector>#include <bitset>#include <cstdio>#include <string>#include <numeric>#include <cstring>#include <cstdlib>#include <iostream>#include <algorithm>#include <functional>using namespace std;typedef long long ll;typedef unsigned long long ull;int dx[4]={-1,1,0,0};int dy[4]={0,0,-1,1};//up down left rightbool inmap(int x,int y,int n,int m){if(x<1||x>n||y<1||y>m)return false;return true;}int hashmap(int x,int y,int m){return (x-1)*m+y;}#define eps 1e-8#define inf 0x7fffffff#define debug puts("BUG")#define lson l,m,rt<<1#define rson m+1,r,rt<<1|1#define read freopen("in.txt","r",stdin)#define write freopen("out.txt","w",stdout)#define maxn 60long long dp[maxn];//dp[j]=dp[j-1]+1+dp[j-3]/** 第一个位置只能放1,则第二个位置可以放2或者3,因此, 1,当第二个位置放2时,有1 (2……),括号里的为2~n,就相当于1~n-1,即dp[n-1] 2,当第二个位置放3时,有1 3 (4……)2和1 3 2 (4……)两种, 2.1,第一种只可能是 1 3 4 6 …… 7 5 2这一种, 2.2,1 3 2 (4……)括号里就相当于1~n-3,即dp[n-3]所以,dp[n]=dp[n-1]+1+dp[n-3]**/int main(){ int n; scanf("%d",&n); dp[0]=0;dp[1]=1;dp[2]=1; for(int i=3;i<=n;i++) dp[i]=dp[i-1]+1+dp[i-3]; printf("%lld\n",dp[n]); return 0;}
- Nudnik Photographer
- 1260. Nudnik Photographer
- 1260. Nudnik Photographer dp
- Ural 1260. Nudnik Photographer
- URAL 1260. Nudnik Photographer
- ural 1260. Nudnik Photographer
- Ural 1260 Nudnik Photographer
- Ural 1260. A nudnik photographer
- Ural 1260. Nudnik Photographer DP
- ural 1260. Nudnik Photographer(dp)
- Nudnik Photographer -Ural1260动态规划
- Ural 1260. A nudnik photographer(dp)
- Ural 1260 A nudnik photographer(DP)
- ural 1260. Nudnik Photographer 规律dp
- timus 1260. Nudnik Photographer 解题报告 URAL 找规律?DP
- URAL 1260 Nudnik Photographer 简单的递推
- C. Photographer
- Photographer (SDUT 2063)
- Android之内存泄漏调试学习与总结(转载)
- Java I/O流-总结(InputStream,OutputStream,Reader,Writer)
- poj 3085 Quick Change
- 关于java Runtime.getRunTime.exec(String command)的使用
- How to think like a Computer Scientist: 课后习题第九章 第2题
- Nudnik Photographer
- 12个必需的iOS开发工具和资源
- 关于生成树 次小生成树
- 提示ORA-03113:通信通道的文件结尾
- 随笔(Qt父子对象的析构:对象模型)
- uitableview 跳转指定区域
- js总结
- 【操作系统面试专题】:为什么要在操作系统中引入线程?
- 南阳oj-29(求转置矩阵问题)解题报告