摘要: http://acm.hdu.edu.cn/showproblem.php?pid=1016素数结,简单dfs,只是前面的prime我开得太小,起先只开到21,可是题目算的是两数之和,最高可达38#include#includeint prime[40]={0,0,1,1,0,1,0,1,0,0,0,1,0,1,0,0,0,1,0,1,0,0,0,1,0,0,0,0,0,1,0,1,0,0,0,0,0,1,0,0};int ans[21],vis[21],n;int print(int x){ int i; for(i=1;i<=x;i++) if(i==1) prin... 阅读全文
posted @ 2013-08-03 16:47 执着追求的IT小小鸟 阅读(148) 评论(0) 推荐(0) 编辑
摘要: http://acm.hdu.edu.cn/showproblem.php?pid=1372简单广搜,秒过,关键在于国际象棋中马的走法是日,我日。。。#include#includeint visited[8][8],dir[8][2]={{-2,-1},{-2,1},{2,-1},{2,1},{-1,-2},{-1,2},{1,-2},{1,2}};//可以走四个方向 int sx,sy,ex,ey;struct node{ int x,y,move;}s[100000];int pd(int a,int b){ return (a=8||b=8);}int bfs(){ i... 阅读全文
posted @ 2013-08-03 15:49 执着追求的IT小小鸟 阅读(152) 评论(0) 推荐(0) 编辑
摘要: http://acm.hdu.edu.cn/showproblem.php?pid=1175这题是1728逃离迷宫的简化版本,也是要找到转弯最少的那个路径。。。不过这题还要将不一样的棋子的连法,及要连接的棋子中存在0的连法删割掉,直接输出NO#include#include#include#define T 2int hash[1000][1000],vis[1000][1000];int n,m,sx,sy,ex,ey,temp;int dir[4][2]={{1,0},{-1,0},{0,1},{0,-1}};struct node{ int x,y,k;//保存坐标和转弯数 }s[1.. 阅读全文
posted @ 2013-08-03 11:22 执着追求的IT小小鸟 阅读(217) 评论(0) 推荐(0) 编辑