#include #include #include #include #include #include #define ll long long #define inf 1e9 #define eps 1e-10 #define md #define N 55 using namespace std; struct data { int x,y,k; double dis; }; struct cmp { bool operator () (data A,data B) { return A.dis>B.dis; } }; priority_queue,cmp> q; double dis[N][N][N]; bool vis[N][N][N]; int a[N][N]; char st[N]; int n,m,K,sx,sy,tx,ty; int lx[4]={-1,0,1,0},ly[4]={0,-1,0,1}; void dj() { for (int i=1;i<=n;i++) for (int j=1;j<=m;j++) for (int k=0;k<=K;k++) dis[i][j][k]=inf; memset(vis,0,sizeof(vis)); while (!q.empty()) q.pop(); dis[sx][sy][K]=0; data hd,ins; hd.x=sx; hd.y=sy; hd.k=K; hd.dis=0; q.push(hd); while (!q.empty()) { hd=q.top(); q.pop(); int i=hd.x,j=hd.y,k=hd.k; double len=dis[i][j][k]; //printf("%d %d %d a:%d dis: %.3lf\n",i,j,k,a[i][j],len); if (vis[i][j][k]) continue; vis[i][j][k]=1; if (i==tx&&j==ty&&k>=1) { printf("%.2lf\n",len); return; } if (k==1) continue; for (int p=0;p<=3;p++) { int x=i+lx[p],y=j+ly[p]; if (x<1||y<1||x>n||y>m||a[x][y]==-1) continue; double ds=len+(double)abs(a[i][j]-a[x][y])/k; //printf(" : %d %d %d a:%d dis:%.3lf\n",x,y,k-1,a[x][y],ds); if (ds