摘要: 这题重要的走过的点可以走第二次,但是我们会发现当走过4时我们可以标记为0,因为回走是没必要#include<stdio.h>#include<stdlib.h>#include<string.h>struct T{ int x,y,time,step; }q[10024];int map[12][12],N,M,x,y;int d[4][2]={ 1,0,0,1,-1,0,0,-1 };int BFS( ){ int first=0,end=0; T t; t.step=0;t.time=6; t.x=x;t.y=y; q[end++]=t; wh... 阅读全文
posted @ 2011-11-18 21:35 wutaoKeen 阅读(181) 评论(0) 推荐(0) 编辑
摘要: 该题是一道典型的BFS题,如果你用DFS你就会要把所有的肯能枚举,而BFS就不需要这样。#include<stdio.h>#include<stdlib.h>struct T{ int x, n; }q[424];int BFS( int n,int k[],int start,int end ){ int first=0,tail=0,hash[224]={0}; T t; hash[start]=1; t.x=start;t.n=0; q[first++]=t; while( first>tail ) { int count=q[t... 阅读全文
posted @ 2011-11-18 17:10 wutaoKeen 阅读(185) 评论(0) 推荐(0) 编辑
摘要: 猜数字刚开始看有点假假的,但是仔细用二分分析时,你就会发现只有2^n-1时,才可能满足猜n次你才能猜对。 1 #include<stdio.h> 2 #include<stdlib.h> 3 __int64 pow( int n ) 4 { 5 __int64 sum=1; 6 for( int i=1;i<=n ;i++) 7 sum*=2; 8 return sum-1; 9 }10 int main()11 {12 int T,n;13 scanf( "%d",&T );14 while( T-- )15 {16 sc... 阅读全文
posted @ 2011-11-18 17:06 wutaoKeen 阅读(186) 评论(0) 推荐(0) 编辑
摘要: 该题WA了上午,呜呜.......最后,幸亏lvsi的提醒,把getsum函数改为long long 型就过了,该题与poj 2992 Divisors是同一类型这里我们就不累叙了,这里要注意的就是2与5的对数,我们就把2与5成对处理掉,因为2*5=10,我们就可以忽略2与5成对的情况; 1 #include<stdio.h> 2 #include<stdlib.h> 3 #include<math.h> 4 #include<string.h> 5 int hash[500024]={0}; 6 int prime[100000]; 7 int 阅读全文
posted @ 2011-11-18 15:38 wutaoKeen 阅读(293) 评论(0) 推荐(0) 编辑