1 #include<iostream>
2 #include<cstdio>
3 #include<cstring>
4 #include<cmath>
5 #include<algorithm>
6 #include<vector>
7 #include<queue>
8 #define rep(i,l,r) for(int i=l;i<r;i++)
9 #define clr(a,x) memset(a,x,sizeof(a))
10 using namespace std;
11 int read()
12 {
13 char c=getchar();
14 while(!isdigit(c)) c=getchar();
15 int ans=0;
16 while(isdigit(c)){
17 ans=ans*10+c-‘0‘;
18 c=getchar();
19 }
20 return ans;
21 }
22 struct edge{
23 int to,v;
24 };
25 struct node{
26 int num,d,f;
27 bool operator <(const node&q)const{
28 return d>q.d;
29 }
30 };
31 const int maxn=55,maxm=1005,maxk=55;
32 int n,m,k,s,t,d[maxn][maxk];
33 bool p[maxn][maxk];
34 priority_queue<node>q;
35 vector<edge>e[maxn];
36 int main()
37 {
38 clr(p,0);
39 node start;
40 start.d=0;
41 start.f=0;
42 start.num=1;
43 n=read();m=read();k=read();
44 rep(i,1,n+1)
45 rep(j,0,k+1)
46 d[i][j]=10000000;
47 d[1][0]=0;
48 while(m--){
49 edge ed;
50 int from=read();
51 ed.to=read();ed.v=read();
52 e[from].push_back(ed);
53 swap(from,ed.to);
54 e[from].push_back(ed);
55 }
56 q.push(start);
57 while(!q.empty()){
58 node now=q.top();
59 q.pop();
60 if(p[now.num][now.f]) continue;
61 p[now.num][now.f]=1;
62 rep(i,0,e[now.num].size()){
63 if(now.d+e[now.num][i].v<d[e[now.num][i].to][now.f]){
64 d[e[now.num][i].to][now.f]=now.d+e[now.num][i].v;
65 node next;
66 next.f=now.f;
67 next.d=d[e[now.num][i].to][now.f];
68 next.num=e[now.num][i].to;
69 q.push(next);
70 }
71 if(now.d+e[now.num][i].v/2<d[e[now.num][i].to][now.f+1]){
72 d[e[now.num][i].to][now.f+1]=now.d+e[now.num][i].v/2;
73 node next;
74 next.f=now.f+1;
75 next.d=d[e[now.num][i].to][now.f+1];
76 next.num=e[now.num][i].to;
77 q.push(next);;
78 }
79 }
80 }
81 int mn=10000000;
82 rep(i,0,k+1) mn=min(mn,d[n][i]);
83 printf("%d",mn);
84 return 0;
85 }