锘??xml version="1.0" encoding="utf-8" standalone="yes"?>亚洲国产成人精品无码久久久久久综合,久久久久久久97,亚洲国产精品无码久久九九 http://www.shnenglu.com/qhpeklh5959/category/20340.html鏌崇誕鍥犻璧?/description>zh-cn Sat, 09 Feb 2013 03:55:57 GMT Sat, 09 Feb 2013 03:55:57 GMT 60 POJ1915 Knight Moves http://www.shnenglu.com/qhpeklh5959/articles/197759.html嫻呴洦姝?/dc:creator>嫻呴洦姝?/author>Wed, 06 Feb 2013 12:18:00 GMT http://www.shnenglu.com/qhpeklh5959/articles/197759.html http://www.shnenglu.com/qhpeklh5959/comments/197759.html http://www.shnenglu.com/qhpeklh5959/articles/197759.html#Feedback 0 http://www.shnenglu.com/qhpeklh5959/comments/commentRss/197759.html http://www.shnenglu.com/qhpeklh5959/services/trackbacks/197759.html 鍙堟槸鍠滈椈涔愯鐨勯獞澹亶鍘嗭紝鍚鍙屽悜騫挎悳鍙互鎻愬崌鏁堢巼錛屼絾鏄弻鍚戝箍鎼滀笉浼氬晩浜層傘?br />view code 1 #include <iostream> 2 #include <cstdio> 3 #include <cstdlib> 4 #include <cstring> 5 #include <cmath> 6 #include <algorithm> 7 #include <queue> 8 using namespace std; 9 int map[310][310], n;10 const int dir[8][2] = {{2, 1}, {2, -1}, {-2, 1}, {-2, -1}, {1, 2}, {1, -2}, {-1, 2}, {-1, -2}};11 struct nod{12 int x, y;13 }S, T;14 queue<nod> Q;15 void init(){16 for (int i = 0; i < n; i++)17 for (int j = 0; j < n; j++)18 map[i][j] = -1;19 }20 bool inMap(int x, int y){21 return x >= 0 && x < n && y >= 0 && y < n;22 }23 void bfs(){24 map[S.x][S.y] = 0;25 Q.push(S);26 while (!Q.empty()){27 nod u = Q.front();28 Q.pop();29 int x = u.x, y = u.y;30 for (int i = 0; i < 8; i++){31 int xx = x + dir[i][0];32 int yy = y + dir[i][1];33 if (!inMap(xx, yy)) continue ;34 if (map[xx][yy] == -1 || map[xx][yy] > map[x][y] + 1){35 map[xx][yy] = map[x][y] + 1;36 nod v; v.x = xx; v.y = yy;37 Q.push(v);38 }39 }40 }41 }42 int main(){43 int t;44 scanf("%d", &t);45 while (t--){46 scanf("%d", &n);47 scanf("%d%d%d%d", &S.x, &S.y, &T.x, &T.y);48 init();49 bfs();50 printf("%d\n", map[T.x][T.y]);51 }52 return 0;53 ]]> POJ3126 Prime Path http://www.shnenglu.com/qhpeklh5959/articles/197687.html嫻呴洦姝?/dc:creator>嫻呴洦姝?/author>Sat, 02 Feb 2013 21:02:00 GMT http://www.shnenglu.com/qhpeklh5959/articles/197687.html http://www.shnenglu.com/qhpeklh5959/comments/197687.html http://www.shnenglu.com/qhpeklh5959/articles/197687.html#Feedback 0 http://www.shnenglu.com/qhpeklh5959/comments/commentRss/197687.html http://www.shnenglu.com/qhpeklh5959/services/trackbacks/197687.html 鏋氫婦姣忎竴浣嶏紝鐪嬫槸涓嶆槸绱犳暟錛屾垜鐨勫垽鏂柟娉曟槸鎵撹〃鍒ゆ柇錛岀劧鍚庢妸絎﹀悎鏉′歡鐨勬柊鏁板姞鍏ュ埌闃熷垪涓互渚夸笅嬈℃悳绱紝綆鍗曠殑騫挎悳棰橈紝灝辨槸鎴戞崏鎬ョ殑鐘簡涓涓綆綰ч敊璇?br />view code 1 #include <iostream> 2 #include <cstdio> 3 #include <cstdlib> 4 #include <cstring> 5 #include <cmath> 6 #include <algorithm> 7 #include <queue> 8 using namespace std; 9 int map[10010], n, k, f, g, h, b, a[10010];10 queue<int > Q;11 void prime(){12 memset(a, -1, sizeof (a));13 a[0] = a[1] = 0;14 for (int i = 2; i <= 100; i++)15 for (int j = i * i; j <= 10000; j += i)16 a[j] = 0;17 }18 int fun(int a, int b, int c, int d){19 return a * 1000 + b * 100 + c * 10 + d;20 }21 void init(int n){22 f = n % 10;23 g = n / 10 % 10;24 h = n / 100 % 10;25 b = n / 1000;26 }27 void bfs(){28 map[n] = 0;29 Q.push(n);30 while (!Q.empty()){31 int x = Q.front();32 init(x);33 Q.pop();34 for (int i = 1; i < 10; i += 2){35 int xx = fun(b, h, g, i);36 if (a[xx] == 0) continue ;37 if (map[xx] == -1 || map[x] + 1 < map[xx]){38 map[xx] = map[x] + 1;39 Q.push(xx);40 }41 }42 for (int i = 0; i < 10; i += 1){43 int xx = fun(b, h, i, f);44 if (a[xx] == 0) continue ;45 if (map[xx] == -1 || map[x] + 1 < map[xx]){46 map[xx] = map[x] + 1;47 Q.push(xx);48 }49 }50 for (int i = 0; i < 10; i += 1){51 int xx = fun(b, i, g, f);52 if (a[xx] == 0) continue ;53 if (map[xx] == -1 || map[x] + 1 < map[xx]){54 map[xx] = map[x] + 1;55 Q.push(xx);56 }57 }58 for (int i = 1; i < 10; i += 1){59 int xx = fun(i, h, g, f);60 if (a[xx] == 0) continue ;61 if (map[xx] == -1 || map[x] + 1 < map[xx]){62 map[xx] = map[x] + 1;63 Q.push(xx);64 }65 }66 }67 }68 int main(){69 int t;70 prime();71 while (~scanf("%d", &t)){72 while (t--){73 scanf("%d%d", &n, &k);74 memset(map, -1, sizeof (map));75 bfs();76 printf("%d\n", map[k]);77 }78 }79 return 0;80 }81 ]]> POJ2243 Knight Moves http://www.shnenglu.com/qhpeklh5959/articles/197632.html嫻呴洦姝?/dc:creator>嫻呴洦姝?/author>Wed, 30 Jan 2013 08:18:00 GMT http://www.shnenglu.com/qhpeklh5959/articles/197632.html http://www.shnenglu.com/qhpeklh5959/comments/197632.html http://www.shnenglu.com/qhpeklh5959/articles/197632.html#Feedback 0 http://www.shnenglu.com/qhpeklh5959/comments/commentRss/197632.html http://www.shnenglu.com/qhpeklh5959/services/trackbacks/197632.html 棰樼洰閾炬帴錛?a style="color: #6a3906; text-decoration: none; ">http://poj.org/problem?id=2243
楠戝+閬嶅巻榪涢樁鐗?br />
view code 1 #include < iostream > 2 #include < cstdio > 3 #include < cstdlib > 4 #include < cstring > 5 #include < cmath > 6 #include < algorithm > 7 #include < queue > 8 using namespace std; 9 int map[ 10 ][ 10 ]; 10 char s1[ 3 ], s2[ 3 ]; 11 const int dir[ 8 ][ 2 ] = {{ 2 , 1 }, { - 2 , 1 }, { 2 , - 1 }, { - 2 , - 1 }, { 1 , 2 }, { - 1 , 2 }, { 1 , - 2 }, { - 1 , - 2 }}; 12 struct data 13 { 14 int x, y; 15 }S, T; 16 queue < data > Q; 17 bool inMap( int x, int y) 18 { 19 return x >= 0 && x < 8 && y >= 0 && y < 8 ; 20 } 21 void init() 22 { 23 S.x = s1[ 0 ] - ' a ' ; 24 S.y = s1[ 1 ] - ' 1 ' ; 25 T.x = s2[ 0 ] - ' a ' ; 26 T.y = s2[ 1 ] - ' 1 ' ; 27 memset(map, - 1 , sizeof (map)); 28 } 29 void bfs() 30 { 31 Q.push(S); 32 map[S.x][S.y] = 0 ; 33 data u, v; 34 while ( ! Q.empty()) 35 { 36 u = Q.front(); 37 Q.pop(); 38 int x = u.x, y = u.y; 39 for ( int i = 0 ; i < 8 ; i ++ ) 40 { 41 int xx = x + dir[i][ 0 ]; 42 int yy = y + dir[i][ 1 ]; 43 if ( ! inMap(xx, yy)) continue ; 44 if (map[xx][yy] == - 1 || map[x][y] + 1 < map[xx][yy]) 45 { 46 map[xx][yy] = map[x][y] + 1 ; 47 v.x = xx; v.y = yy; 48 Q.push(v); 49 } 50 } 51 } 52 } 53 int main() 54 { 55 while ( ~ scanf( " %s%s " , s1, s2)) 56 { 57 init(); 58 bfs(); 59 printf( " To get from %s to %s takes %d knight moves.\n " , s1, s2, map[T.x][T.y]); 60 } 61 return 0 ; 62 } 63 ]]>POJ2251 Dungeon Master http://www.shnenglu.com/qhpeklh5959/articles/197631.html嫻呴洦姝?/dc:creator>嫻呴洦姝?/author>Wed, 30 Jan 2013 07:19:00 GMT http://www.shnenglu.com/qhpeklh5959/articles/197631.html http://www.shnenglu.com/qhpeklh5959/comments/197631.html http://www.shnenglu.com/qhpeklh5959/articles/197631.html#Feedback 0 http://www.shnenglu.com/qhpeklh5959/comments/commentRss/197631.html http://www.shnenglu.com/qhpeklh5959/services/trackbacks/197631.html 棰樼洰閾炬帴錛?a style="color: #6a3906; text-decoration: none; ">http://poj.org/problem?id=2251鎴戣兘璇存垜涓涓婃潵灝辮棰樼洰鎻忚堪鍚撳埌浜嗭紝鐒跺悗鍙堣棰樻剰鍚撳埌浜嗕箞錛?/p>
鍏跺疄瀹冪殑鏈川鏄竴閬撲笉鎶樹笉鎵g殑姘撮錛屽父瑙勭殑涓夌淮絀洪棿騫挎悳錛屽啓鐫鍐欑潃灝卞嚭鏉ヤ簡錛屼腑闂村洜涓鴻鍧愭爣闂緇曡挋鍦堜簡鍐欎簡寰堝閿欒錛屼絾鏄渶鍚庢嫄鍥炴潵浜嗭紝絀洪棿鎯寵薄鍔涙槸涓激鍟娿傘?br />
view code 1 #include < iostream > 2 #include < cstdio > 3 #include < cstdlib > 4 #include < cstring > 5 #include < cmath > 6 #include < algorithm > 7 #include < queue > 8 using namespace std; 9 struct data 10 { 11 int x, y, z; 12 }S, T; 13 const int dir[ 6 ][ 3 ] = {{ 1 , 0 , 0 }, { - 1 , 0 , 0 }, { 0 , 1 , 0 }, { 0 , - 1 , 0 }, { 0 , 0 , 1 }, { 0 , 0 , - 1 }}; 14 queue < data > Q; 15 char s[ 35 ][ 35 ]; 16 int l, r, c, map[ 35 ][ 35 ][ 35 ], G[ 35 ][ 35 ][ 35 ]; 17 bool inMap( int x, int y, int z) 18 { 19 return x >= 0 && x < l && y >= 0 && y < r && z >= 0 && z < c; 20 } 21 void init() 22 { 23 for ( int i = 0 ; i < l; i ++ ) 24 for ( int j = 0 ; j < r; j ++ ) 25 for ( int k = 0 ; k < c; k ++ ) 26 { 27 if (G[i][j][k] == 2 ) {S.x = i; S.y = j; S.z = k;} 28 if (G[i][j][k] == 3 ) {T.x = i; T.y = j; T.z = k;} 29 } 30 memset(map, - 1 , sizeof (map)); 31 } 32 void bfs() 33 { 34 Q.push(S); 35 map[S.x][S.y][S.z] = 0 ; 36 data u, v; 37 while ( ! Q.empty()) 38 { 39 u = Q.front(); 40 Q.pop(); 41 int x = u.x, y = u.y, z = u.z; 42 for ( int i = 0 ; i < 6 ; i ++ ) 43 { 44 int xx = x + dir[i][ 0 ]; 45 int yy = y + dir[i][ 1 ]; 46 int zz = z + dir[i][ 2 ]; 47 if ( ! inMap(xx, yy, zz) || G[xx][yy][zz] == 1 ) continue ; 48 if (map[xx][yy][zz] == - 1 || map[x][y][z] + 1 < map[xx][yy][zz]) 49 { 50 map[xx][yy][zz] = map[x][y][z] + 1 ; 51 v.x = xx; v.y = yy; v.z = zz; 52 Q.push(v); 53 } 54 } 55 } 56 } 57 int main() 58 { 59 while ( ~ scanf( " %d%d%d " , & l, & r, & c)) 60 { 61 if ( ! (l + r + c)) break ; 62 for ( int i = 0 ; i < l; i ++ ) 63 { 64 for ( int j = 0 ; j < r; j ++ ) scanf( " %s " , s[j]); 65 for ( int j = 0 ; j < r; j ++ ) 66 for ( int k = 0 ; k < c; k ++ ) 67 { 68 if (s[j][k] == ' # ' ) G[i][j][k] = 1 ; 69 if (s[j][k] == ' . ' ) G[i][j][k] = 0 ; 70 if (s[j][k] == ' S ' ) G[i][j][k] = 2 ; 71 if (s[j][k] == ' E ' ) G[i][j][k] = 3 ; 72 } 73 } 74 init(); 75 bfs(); 76 if (map[T.x][T.y][T.z] == - 1 ) printf( " Trapped!\n " ); 77 else printf( " Escaped in %d minute(s).\n " , map[T.x][T.y][T.z]); 78 } 79 return 0 ; 80 } 81 ]]> POJ3278 Catch That Cow http://www.shnenglu.com/qhpeklh5959/articles/197453.html嫻呴洦姝?/dc:creator>嫻呴洦姝?/author>Mon, 21 Jan 2013 19:00:00 GMT http://www.shnenglu.com/qhpeklh5959/articles/197453.html http://www.shnenglu.com/qhpeklh5959/comments/197453.html http://www.shnenglu.com/qhpeklh5959/articles/197453.html#Feedback 0 http://www.shnenglu.com/qhpeklh5959/comments/commentRss/197453.html http://www.shnenglu.com/qhpeklh5959/services/trackbacks/197453.html 棰樼洰閾炬帴錛?a style="color: #6a3906; text-decoration: initial;">http://poj.org/problem?id=3278鎴戜細璇磋繖鏄垜浜虹敓涓涓閬撳箍鎼滈涔堬紵錛?br />
view code 1 #include < iostream > 2 #include < cstdio > 3 #include < cstdlib > 4 #include < cstring > 5 #include < cmath > 6 #include < algorithm > 7 using namespace std; 8 #define maxn 100010 9 #define maxl 500010 10 int dir[ 3 ][ 2 ] = {{ 1 , 1 }, { 1 , - 1 }, { 2 , 0 }}; 11 int timet[maxn], S, T, q[maxl]; 12 int n, k; 13 void init() 14 { 15 for ( int i = 0 ; i < maxn; i ++ ) timet[i] = - 1 ; 16 S = n; T = k; 17 } 18 bool IN( int x) 19 { 20 return x >= 0 && x <= maxn; 21 } 22 void bfs() 23 { 24 int h = 0 , t = 0 ; 25 timet[S] = 0 ; 26 q[t] = S; 27 t ++ ; 28 while (h != t) 29 { 30 int x = q[h]; 31 h = h % maxl + 1 ; 32 for ( int i = 0 ; i < 3 ; i ++ ) 33 { 34 int xx = x * dir[i][ 0 ] + dir[i][ 1 ]; 35 if ( ! IN(xx)) continue ; 36 if (timet[xx] == - 1 || timet[x] + 1 < timet[xx]) 37 { 38 timet[xx] = timet[x] + 1 ; 39 q[t] = xx; 40 t = t % maxl + 1 ; 41 } 42 } 43 } 44 } 45 int main() 46 { 47 while ( ~ scanf( " %d%d " , & n, & k)) 48 { 49 init(); 50 bfs(); 51 printf( " %d\n " , timet[T]); 52 } 53 return 0 ; 54 } 55 ]]>
久久本道综合久久伊人 |
伊人 久久 精品 |
久久精品国产亚洲AV香蕉 |
亚洲精品无码久久千人斩 |
久久久久久综合一区中文字幕 |
91精品久久久久久无码 |
欧美亚洲色综久久精品国产 |
久久影视综合亚洲 |
丰满少妇人妻久久久久久4 |
久久香综合精品久久伊人 |
国产精品无码久久久久 |
成人午夜精品无码区久久 |
久久成人精品 |
国产成人精品白浆久久69 |
久久精品国产乱子伦 |
深夜久久AAAAA级毛片免费看 |
久久国产成人精品麻豆 |
久久国产欧美日韩精品 |
久久久久九九精品影院 |
免费一级欧美大片久久网
|
国产一区二区三区久久精品 |
久久国产福利免费 |
99999久久久久久亚洲 |
av无码久久久久不卡免费网站 |
久久亚洲AV无码西西人体 |
久久综合狠狠色综合伊人 |
久久久久国产精品熟女影院
|
久久SE精品一区二区 |
国内精品久久久久久麻豆
|
99久久国产综合精品女同图片 |
久久www免费人成精品香蕉 |
中文精品久久久久国产网址 |
精品久久久无码人妻中文字幕豆芽
|
亚洲午夜久久久久久久久电影网 |
久久久久噜噜噜亚洲熟女综合 |
72种姿势欧美久久久久大黄蕉 |
久久婷婷五月综合97色 |
久久精品国产精品亚洲毛片 |
亚洲成色www久久网站夜月
|
日本精品久久久久中文字幕8 |
精品一区二区久久 |