Problem Description
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 N persons, 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:
  1. The 1 year old student is to sit at the left end of the row.
  2. 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
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).
 
#include <stdio.h>

typedef __int64 LL;

int main(){
LL a[];
a[]=;
a[]=;
a[]=;
a[]=;
for(int i=; i<=; i++){
a[i]=a[i-]+a[i-]+;
}
int n;
while( scanf("%d",&n)!=EOF ){
printf("%I64d\n",a[n]);
}
return ;
}
 

Ural 1260 Nudnik Photographer的更多相关文章

  1. 递推DP URAL 1260 Nudnik Photographer

    题目传送门 /* 递推DP: dp[i] 表示放i的方案数,最后累加前n-2的数字的方案数 */ #include <cstdio> #include <algorithm> ...

  2. URAL 1260 Nudnik Photographer(递推)

    题目链接 题意 : 给你1到n这n个数,排成一排,然后1放在左边最开始,剩下的数进行排列,要求排列出来的数列必须满足任何两个相邻的数之间的差不能超过2,问你有多少种排列 思路 : 对于dp[n], n ...

  3. URAL 1260 Nudnik Photographer DFS DP

    题目:click here :这个题可以先dfs深搜下,规律dp dfs: #include <bits/stdc++.h> using namespace std; #define S ...

  4. Ural 1260 A nudnik photographer(DP)

    A nudnik photographer 大意: 对1到N这些数进行排列,1必需要在最左边.相邻的两个数之间的差值不能超过2,问有多少种排列的方法. 思路: 对座位进行DP,当第一个是1,第二个是2 ...

  5. Nudnik Photographer -Ural1260动态规划

    Time limit: 1.0 second Memory limit: 64 MB If two people were born one after another with one second ...

  6. URAL DP第一发

    列表: URAL 1225 Flags URAL 1009 K-based Numbers URAL 1119 Metro URAL 1146 Maximum Sum URAL 1203 Scient ...

  7. URAL(DP集)

    这几天扫了一下URAL上面简单的DP 第一题 简单递推 1225. Flags #include <iostream> #include<cstdio> #include< ...

  8. 【DP】HDU 1260

    HDU 1260 Tickets 题意:有N个人要买票,你可以一个一个人卖票,时间分别为Xs,也可以相邻两个人一起卖票,时间为Ys,从早上八点开始卖票,问你何时最早将N个人的票卖完. 思路:解决情况是 ...

  9. [BZOJ 1260][CQOI2007]染色(DP)

    题目:http://www.lydsy.com:808/JudgeOnline/problem.php?id=1260 分析: f[i][j]表示i~j刷成s[i]~s[j]这个样子需要的最小次数 则 ...

随机推荐

  1. Java变量的修饰符

    1.public public的类.类属变量及方法,包内及包外的任何类均可以访问: 2.protect protected的类.类属变量及方法,包内的任何类,及包外的那些继承了此类的子类才能访问: 3 ...

  2. aspx 与 ashx cs

    1. aspx 与 ashx 我们知道 aspx :继承自 System.Web.UI.Page 然而Page:IHttpHandler public class Page : TemplateCon ...

  3. 数据库连接工具HeidiSql介绍(支持MySQL,MariaDB,Microsoft SQL或PostgreSQL)

    前言 Navicat作为比较老牌的数据库连接工具知名度比较广,功能也比较完善,但对入门的广大初学者来讲,怎么去找安装的资源包是一大难题,虽然经过一些“渠道”能找到可以正常使用的绿色安装包,但从长期来讲 ...

  4. 阿里云RDS外网无法访问解决办法

    为了安全起见,阿里云的RDS数据库设置只能内网连接,那么为了方便查询数据,我每次都去连接内网服务器远程桌面. 这次我因为网络问题,远程桌面非常不稳定,一会掉线一会掉线,只能另想办法. 同事那里有个批处 ...

  5. C#静态类 静态方法与非静态方法比较

    静态类 在类(class)上加入static修饰,表示该类无法被实例化,并将该类中,无法实例化变量或函数 静态类的主要特性 仅包含静态成员 无法实例化 静态类的本质,时一个抽象的密封类,所以不能被继承 ...

  6. Vue vue-resource发送Http请求

    vue-resource 1.cnpm install vue-resource --save 2.在main.js中import VueResource from 'vue-resource' 3. ...

  7. SQL Server 根据关键字和结束符提取字符串子串

    /* @info-待截取的字符串 @indexStr-截取子串的起始字符串 @split-截取子串的结束符号 列入依次传入 胸片:正常.心电图:异常,需要注意.血常规检查:正常. 心电图 '.' 返回 ...

  8. django修改数据库连接

    settings.py DATABASES = { 'default': { 'ENGINE': 'django.db.backends.mysql', 'NAME': 'domain', 'USER ...

  9. B. Spreadsheets(进制转换,数学)

    B. Spreadsheets time limit per test 10 seconds memory limit per test 64 megabytes input standard inp ...

  10. centos6.3安装 jdk-8u131-linux-x64.gz

    解压指令为:tar -zxvf jdk-8u131-linux-x64.gz 设置环境变量,首先是打开设置环境变量的文件夹,指令为:vi /etc/profile     然后在英文输入法下切换到“插 ...