先搜索 出来一点结果之后  看结果之间的 联系 得出  递推公式  .

 #include<stdio.h>
#include<string.h>
#include<math.h>
#include<iostream>
#include<limits.h>
#include<algorithm>
#include<queue>
#include<vector>
#include<set>
#include<stack>
#include<string>
#include<sstream>
#include<map>
#include<cctype>
using namespace std;
int visited[],result[],flag,n;
void DFS(int mark)
{
if(mark==n)
flag++;
else
{
for(int i=;i<=n;i++)
{
if(abs(i-result[mark])<=&&!visited[i])
{
result[mark+]=i;
visited[i]=;
DFS(mark+);
visited[i]=;
}
}
}
}
int main()
{
while(scanf("%d",&n)!=EOF)
{
memset(visited,,sizeof(visited));
visited[]=result[]=;
flag=;
DFS();
printf("%d\n",flag);
}
return ;
}

可以通过一些 结果推出来  递推公式

 #include<stdio.h>
#include<string.h>
#include<math.h>
#include<iostream>
#include<limits.h>
#include<algorithm>
#include<queue>
#include<vector>
#include<set>
#include<stack>
#include<string>
#include<sstream>
#include<map>
#include<cctype>
using namespace std;
int main()
{
int n,ac[]={,,,};
for(int i=;i<=;i++)
ac[i]=ac[i-]+ac[i-]+;
while(~scanf("%d",&n))
{
printf("%d\n",ac[n]);
}
return ;
}

擅长排列的小明II的更多相关文章

  1. 擅长排列的小明 II(找规律)

    擅长排列的小明 II 时间限制:1000 ms  |  内存限制:65535 KB 难度:3 描述 小明十分聪明,而且十分擅长排列计算. 有一天小明心血来潮想考考你,他给了你一个正整数n,序列1,2, ...

  2. NYOJ 469 擅长排列的小明 II

    擅长排列的小明 II 时间限制:1000 ms  |  内存限制:65535 KB 难度:3   描述 小明十分聪明,而且十分擅长排列计算. 有一天小明心血来潮想考考你,他给了你一个正整数n,序列1, ...

  3. NYOJ469 - 擅长排列的小明 II - (dp)

    题目描述: 小明十分聪明,而且十分擅长排列计算. 有一天小明心血来潮想考考你,他给了你一个正整数n,序列1,2,3,4,5......n满足以下情况的排列: 1.第一个数必须是1 2.相邻两个数之差不 ...

  4. NYOJ-469 擅长排列的小明 II AC 分类: NYOJ 2014-01-02 22:19 159人阅读 评论(0) 收藏

    最初的第一印象是和组合数一个性质的题目.所以用了回溯法,结果,你懂的... #include<stdio.h> #include<math.h> void dfs(int n, ...

  5. ACM 擅长排列的小明

    擅长排列的小明 时间限制:1000 ms  |  内存限制:65535 KB 难度:4   描述 小明十分聪明,而且十分擅长排列计算.比如给小明一个数字5,他能立刻给出1-5按字典序的全排列,如果你想 ...

  6. nyoj 19擅长排列的小明 (DFS)

    擅长排列的小明 时间限制:1000 ms  |  内存限制:65535 KB 难度:4   描述 小明十分聪明,而且十分擅长排列计算.比如给小明一个数字5,他能立刻给出1-5按字典序的全排列,如果你想 ...

  7. nyoj-0469-擅长排列的小明 II(找规律)

    nyoj-0469-擅长排列的小明 II 思路:递推分析:为了简便起见,我们用Ai代表第i个数字 , 由于A1一直是1,所以A2只能是2或3.假设dp[n]表示1->n这个序列的方案数      ...

  8. nyoj 题目19 擅长排列的小明

    擅长排列的小明 时间限制:1000 ms  |  内存限制:65535 KB 难度:4   描述 小明十分聪明,而且十分擅长排列计算.比如给小明一个数字5,他能立刻给出1-5按字典序的全排列,如果你想 ...

  9. nyist oj 19 擅长排列的小明(dfs搜索+STL)

    擅长排列的小明 时间限制:1000 ms  |  内存限制:65535 KB 难度:4 描写叙述 小明十分聪明.并且十分擅长排列计算.比方给小明一个数字5,他能立马给出1-5按字典序的全排列,假设你想 ...

随机推荐

  1. HDU-1022Train Problem I,简单栈模拟;

    Train Problem I                                                                                     ...

  2. MVC Ajax.BeginForm重复提交解决方法

    mvc使用MVC Ajax.BeginForm提交的时候有重复提交结果的时候检查相关js文件引用情况, 其中mvc4注意 1 2 3 4 @Scripts.Render("~/bundles ...

  3. Linux操作系统下IPTables配置

    filter表的防火墙 1.查看本机关于IPTABLES的设置情况 [root@tp ~]# iptables -L -n Chain INPUT (policy ACCEPT) target pro ...

  4. hdu - 1113 Word Amalgamation (stl)

    http://acm.hdu.edu.cn/showproblem.php?pid=1113 给定一个字典,然后每次输入一个字符串问字典中是否有单词与给定的字符串的所有字母一样(顺序可以打乱),按字典 ...

  5. HDU——3072 Intelligence System

    Intelligence System Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Othe ...

  6. sql语句在Mysql中如何执行?

    1.MySQL 主要分为 Server 层和引擎层,Server 层主要包括连接器.查询缓存.分析器.优化器.执行器,同时还有一个日志模块(binlog),这个日志模块所有执行引擎都可以共用,redo ...

  7. Spring boot精要

    1.自动配置:针对很多Spring应用程序的常见应用功能,SpringBoot能自动提供相关配置: 2.起步依赖:告诉SpringBoot需要什么功能,他就能引入需要的库: 3.命令行界面:这是Spr ...

  8. Servlet的HelloWorld实例

    以下内容引用自http://wiki.jikexueyuan.com/project/servlet/first-example.html: Servlets是Java类,服务于HTTP请求并实现了j ...

  9. 001 Cisco router prewired

    Cisco router 预配: Router>en Router#config t Enter configuration commands, one per line.  End with ...

  10. [Spring] Properties for project configuration

    We might have some project specific configuration need to setup. The good approach to do this in Spr ...