摘要:        
http://poj.org/problem?id=2251	刷水题好爽!但是别真跟xcy说的一样,把rp都给用完了...	三维空间的bfs,只是搜索的时候多了两个方向而已。code:#include<cstdio>#include<cstring>boolvis[31][31][31];intlve[6]={1,0,0,0,0,-1};introw[6]={0,-1,0,0,1,0};intcol[6]={0,0,-1,1,0,0};boolflag;inta,b,c;structnode{intx;inty;intz;intstep;}q[1000000];node    阅读全文
        posted @ 2012-02-16 03:18
追逐.
阅读(197)
评论(0)
推荐(0)
            
        
        
摘要:        
http://poj.org/problem?id=3126	给两个素数,求第一个素数转变成第二个素数所需最小步骤数。每次转换只能改变一位,且转换的中间数都为素数。	最短路径问题,打出一个素数表,对4位数的各个位置0..9暴搜。	比较郁闷的是sqrt()和pow()中必须要用强制转换才行,不记得以前要这样用啊??CE了几次。code:#include<cstdio>#include<cmath>#include<cstring>usingnamespacestd;boolprim[10000];boolvis[10000];intq[1000];voidge    阅读全文
        posted @ 2012-02-16 01:48
追逐.
阅读(246)
评论(0)
推荐(0)
            
        
        
摘要:        
http://poj.org/problem?id=2676	单纯的dfs,用三个数组记录行、列以及3×3方格的情况。	只是一开始不知道为什么没办法结束程序的运行,提交两次TLE,感觉应该是getchar()的问题。code:#include<cstdio>#include<iostream>#include<cstring>usingnamespacestd;boolc[10][10];boolr[10][10];bools[4][4][10];boolvis[10][10];charstr[10];intdata[10][10];boolfla    阅读全文
        posted @ 2012-02-16 00:22
追逐.
阅读(240)
评论(0)
推荐(0)
 
                    
                     
                    
                 
                    
                 
 
         浙公网安备 33010602011771号
浙公网安备 33010602011771号