摘要: <a href="http://acm.hdu.edu.cn/showproblem.php?pid=4033">http://acm.hdu.edu.cn/showproblem.php?pid=4033</a> 思路:二分 先找 两边之和的最小max 和两边只差的最大 min 则边的长度 L 必然 min<l<max 然后二分求解 注意啊,一开始定义 eps 是为e-6,wa 改为e-8 ac #include<stdio.h>#define N 1000#include<math.h>#define eps 阅读全文
posted @ 2012-04-05 20:45 Szz 阅读(186) 评论(0) 推荐(0)
摘要: http://acm.hdu.edu.cn/showproblem.php?pid=4033思路:二分 先找 两边之和的最小max 和两边只差的最大 min 则边的长度 L 必然 min<l<max 然后二分求解 注意啊,一开始定义 eps 是为e-6,wa 改为e-8 ac #include<stdio.h>#define N 1000#include<math.h>#define eps 1e-8const double pi=2*acos(-1);double a[N];int main(){ int T,l,i,n; scanf("%d&q 阅读全文
posted @ 2012-04-05 20:43 Szz 阅读(177) 评论(0) 推荐(0)
摘要: 1http://acm.hdu.edu.cn/showproblem.php?pid=4034 vis[][]作用是 防止一条边被删多次 2 3 #include<stdio.h> 4 #include<string.h> 5 #define N 1000 6 int ans; 7 int map[N][N],n,f,vis[N][N]; 8 void search() 9 {10 int i,j,k;11 memset(vis,0,sizeof(vis));12 for(k=1;k<=n;k++)13 {14 for(i=1;i<=n;i+... 阅读全文
posted @ 2012-04-05 19:29 Szz 阅读(169) 评论(0) 推荐(0)
摘要: http://poj.org/problem?id=2251#include<stdio.h>#include<string.h>#include<queue>#include<iostream>using namespace std;#define max 999999#define N 40int l,r,c,ans,ex,ey,ez;char map[N][N][N];int vis[N][N][N];int dx[6]={-1,0,1,0,0,0};int dy[6]={0,1,0,-1,0,0};int dz[6]={0,0,0,0,1 阅读全文
posted @ 2012-04-03 21:48 Szz 阅读(144) 评论(0) 推荐(0)
摘要: http://poj.org/problem?id=1321#include<stdio.h>#include<string.h>#define N 100char str[N][N];int n,ans,k,r[N],c[N],l;struct node{ int x; int y;}p[N];void dfs(int num,int sum){ if(num<=l&&sum==0) { ans++; return ; } if(num>=l) { return ; } int x=p[num].... 阅读全文
posted @ 2012-04-03 20:27 Szz 阅读(144) 评论(0) 推荐(0)
摘要: http://poj.org/problem?id=3009题意:溜石游戏。在一给定大小的矩形冰面上,散布若干石块,给定石头的初始位置和终点,求从起点到达终点的最小步数,超过10次则视作不可达。其中规则如下,若石头与石块有相邻则不能向该方向滑动;每次溜石只能到达有石块的地方,且将其立即敲碎;若出界则视作失败。思路:限制条件较多的dfs,每个状态下有四个方向的选择,注意每个滑动方向中的情况,较繁琐。#include<stdio.h>#include<iostream>const int inf=999999;using namespace std;int r,c,step 阅读全文
posted @ 2012-04-02 21:22 Szz 阅读(266) 评论(0) 推荐(0)
摘要: /*思路 : 优先队列 bfs ,从每一天中 病毒类型最小的开始 ,所以优先队列 先 按天 排在按类型 */ #include<iostream>#include<stdio.h>#include<queue>#include<cmath>#include<string.h>#define N 600using namespace std;struct node{ int x; int y; int day; int ty; friend bool operator < (struct node a,struct node b) 阅读全文
posted @ 2012-04-01 21:19 Szz 阅读(137) 评论(0) 推荐(0)
摘要: http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=1849/*思路 : 优先队列 bfs ,从每一天中 病毒类型最小的开始 ,所以优先队列 先 按天 排在按类型 */#include<iostream>#include<stdio.h>#include<queue>#include<cmath>#include<string.h>#define N 600using namespace std;struct node{ int x; int y; int day; i 阅读全文
posted @ 2012-04-01 21:01 Szz 阅读(126) 评论(0) 推荐(0)
摘要: http://poj.org/problem?id=3083一开始没明白题意以为只是简单的(顺时针或逆时针),wa一次。。。。1、至于求最短距离,毋庸置疑,肯定是bfs,这个就不多说了2、对于向左和向右的理解上,我当初一直不明白,读了老长时间,没有看懂,到discuss里看了一个人的叙述,终于明白意思了……就是这样,一直沿着向左或向右的方向走,能走就走,不能走就回撤,所以这个dfs不能标记遍历过的点,这是很显然的。3、dfs方向的选择,就是要保证沿着向左或者向右的方向走( 向左是顺时针,向右是逆时针转)#include<stdio.h>#include<string.h> 阅读全文
posted @ 2012-03-30 21:41 Szz 阅读(159) 评论(0) 推荐(0)
摘要: 题意 马走完整个棋盘的路径 (注意 搜索的顺序)http://poj.org/problem?id=2488#include<stdio.h>#include<string.h>#define N 100int d[8][2]={{-2,-1},{-2,1},{-1,-2},{-1,2},{1,-2},{1,2},{2,-1},{2,1}};int m[N],f,k,r,c,vis[N][N],read[N][N];void dfs(int x,int y,int k){ int i; if(f==1)return ; read[k][0]=x; read[k][1]. 阅读全文
posted @ 2012-03-29 16:13 Szz 阅读(199) 评论(0) 推荐(0)