Solutions/Fanta's Solution PKU 2243. Knight Moves. AC 지환태 2009. 5. 31. 16:17 #include int table[8][8]; void fill(int y, int x, int n) { if(table[y][x] <= n) return; if(y>7 || x>7 || y<0 || x<0) return; table[y][x]=n; fill(y-2, x-1, n+1); fill(y-2, x+1, n+1); fill(y+2, x-1, n+1); fill(y+2, x+1, n+1); fill(y-1, x-2, n+1); fill(y-1, x+2, n+1); fill(y+1, x-2, n+1); fill(y+1, x+2, n+1); return; } int main() { char point[3]; while(~scanf("%s", point)) { memset(table, 99, sizeof(int)*8*8); fill(point[1]-'1', point[0]-'a', 0); printf("To get from %s ",point); scanf("%s", point); printf("to %s takes %d knight moves.\n", point, table[point[1]-'1'][point[0]-'a']); } } Run ID User Problem Result Memory Time Language Code Length Submit Time 5217042 jht009 2243 Accepted 204K 297MS C 674B 2009-05-24 20:18:35 그냥 백트래킹으로 채웠습니다.