#include "bits/stdc++.h"

using namespace std;

typedef vector<int> vi;
typedef pair<int,int> pii;
typedef long long ll;

#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back
#define INF 999999999

int c,n,m;
int pass[200][200];

double d[200][20];
bool used[200][20];

int dijk(int s,int g){
    rep(i,200)rep(j,20){
        d[i][j]=INF;
        used[i][j]=false;
    }
    
    d[s][c]=0;
    
    while(1){
        int v=-1;
        int w=-1;
        rep(u,n){
            rep(i,c+1){
                if( !used[u][i] && (v==-1||d[u][i]<d[v][w]) )v=u,w=i;
            }
        }
        if(v==-1)break;
        
        used[v][w]=true;
        
        rep(u,n){
            d[u][w] = min(d[u][w] , d[v][w] + pass[v][u] );
//            cout<<"d["<<u<<"]["<<w<<"]="<<d[u][w]<<endl;
            if(w-1>=0 && pass[v][u]!=INF){
                d[u][w-1] = min(d[u][w-1] , d[v][w] + (pass[v][u]/2.0) );
//                cout<<"d["<<u<<"]["<<w-1<<"]="<<d[u][w-1]<<endl;
            }
        }
    }
    double ret=INF;
    rep(i,c+1){
        ret = min(ret,d[g][i]);
    }
    return ret;
}


int main(){
    int s,g;
    while(cin>>c>>n>>m>>s>>g){
        if(c==0&&n==0&&m==0&&s==0&&g==0)break;
        
        s--,g--;
        rep(i,200)rep(j,200)pass[i][j]=INF;
        rep(i,200)pass[i][i]=0;
        
        rep(i,m){
            int a,b,f;
            cin>>a>>b>>f;
            a--,b--;
            pass[a][b]=pass[b][a]=f;
        }
        
    cout<<dijk(s,g)<<endl;
    }
}