1 #include<cstdio>
2 #include<cstdlib>
3 #include<cmath>
4 #include<cstring>
5 #include<algorithm>
6 #include<iostream>
7 #include<vector>
8 #include<map>
9 #include<set>
10 #include<queue>
11 #define inf 1000000000
12 #define maxn 10000+100
13 #define maxm 50000+100
14 #define eps 1e-10
15 #define ll long long
16 #define pa pair<int,int>
17 using namespace std;
18 inline int read()
19 {
20 int x=0,f=1;char ch=getchar();
21 while(ch<‘0‘||ch>‘9‘){if(ch==‘-‘)f=-1;ch=getchar();}
22 while(ch>=‘0‘&&ch<=‘9‘){x=10*x+ch-‘0‘;ch=getchar();}
23 return x*f;
24 }
25 int n,m,k,tot;
26 int d[maxn][25],head[maxn];
27 bool v[maxn][25];
28 struct edge{int go,next,w;}e[2*maxm];
29 void ins(int x,int y,int z)
30 {
31 e[++tot].go=y;e[tot].w=z;e[tot].next=head[x];head[x]=tot;
32 }
33 void insert(int x,int y,int z)
34 {
35 ins(x,y,z);ins(y,x,z);
36 }
37 void dijkstra()
38 {
39 priority_queue<pa,vector<pa>,greater<pa> >q;
40 for(int i=1;i<=n;i++)
41 for(int j=0;j<=k;j++)
42 d[i][j]=inf;
43 memset(v,0,sizeof(v));
44 d[1][0]=0;q.push(make_pair(0,1));
45 while(!q.empty())
46 {
47 int x=q.top().second;q.pop();
48 int z=x/(n+1);x=x%(n+1);
49 if(v[x][z])continue;v[x][z]=1;
50 for(int i=head[x],y;i;i=e[i].next)
51 {
52 if(d[x][z]+e[i].w<d[y=e[i].go][z])
53 {
54 d[y][z]=d[x][z]+e[i].w;
55 q.push(make_pair(d[y][z],z*(n+1)+y));
56 }
57 if(z==k)continue;
58 if(d[x][z]<d[y][z+1])
59 {
60 d[y][z+1]=d[x][z];
61 q.push(make_pair(d[y][z+1],(z+1)*(n+1)+y));
62 }
63 }
64 }
65 }
66 int main()
67 {
68 freopen("input.txt","r",stdin);
69 freopen("output.txt","w",stdout);
70 n=read();m=read();k=read();
71 for(int i=1;i<=m;i++)
72 {
73 int x=read(),y=read(),z=read();
74 insert(x,y,z);
75 }
76 dijkstra();
77 printf("%d\n",d[n][k]);
78 return 0;
79 }