Language: C++

#include<iostream>
#include<vector>
#include<queue>
using namespace std;

struct edge{
	int cost,limit;
	edge(int c,int l){
		cost=c;limit=l;
	}
};

#define INF 1000000

struct Node{
	int now,speed,before;
	double time;
	Node(int n,int s,double t,int bef){
		now=n;speed=s;time=t;before=bef;
	}
};

bool operator < (Node a,Node b){
	return a.time>b.time;
}

int n,m,s,g;

void solve(){
	vector<vector<edge> > E(n+1,vector<edge>(n+1,edge(-1,-1)));
	cin>>s>>g;
	for(int i=0;i<m;i++){
		int in,out,c,l;
		cin>>in>>out>>c>>l;
		E[in][out]=edge(c,l);
		E[out][in]=edge(c,l);
	}
	vector<vector<double> > Ans(n+1,vector<double>(31,INF));

	priority_queue<Node> Q;
	Q.push(Node(s,0,0.0,s));
	while(!Q.empty()){
		Node t=Q.top(); Q.pop();
		if(Ans[t.now][t.speed]<t.time) continue;		
//		cout<<t.now<<" "<<t.speed<<" "<<t.time<<endl;
		if(t.now==g && t.speed==1){printf("%.12lf\n", t.time );  return;}
		Ans[t.now][t.speed]=t.time;

		for(int i=0;i<=n;i++){
			if(i==t.before) continue;
			if(E[t.now][i].cost>0){
				if(E[t.now][i].limit>=t.speed && t.speed>=1)
					Q.push(Node(i,t.speed,t.time+E[t.now][i].cost/(double)t.speed,t.now));

				if(E[t.now][i].limit>=t.speed+1)
					Q.push(Node(i,t.speed+1,t.time+E[t.now][i].cost/(double)(t.speed+1.0),t.now));

				if(E[t.now][i].limit>=t.speed-1 && t.speed-1>=1)
					Q.push(Node(i,t.speed-1,t.time+E[t.now][i].cost/(double)(t.speed-1.0),t.now));
			}
		}
	}
	cout<<"unreachable"<<endl;
}

int main()
{
	while(cin>>n>>m && n!=0)
		solve();
	return 0;
}
#include<iostream>
#include<vector>
#include<queue>
using namespace std;

struct edge{
	int cost,limit;
	edge(int c,int l){
		cost=c;limit=l;
	}
};

#define INF 1000000

struct Node{
	int now,speed,before;
	double time;
	Node(int n,int s,double t,int bef){
		now=n;speed=s;time=t;before=bef;
	}
};

bool operator < (Node a,Node b){
	return a.time>b.time;
}

int n,m,s,g;

void solve(){
	vector<vector<edge> > E(n+1,vector<edge>(n+1,edge(-1,-1)));
	cin>>s>>g;
	for(int i=0;i<m;i++){
		int in,out,c,l;
		cin>>in>>out>>c>>l;
		E[in][out]=edge(c,l);
		E[out][in]=edge(c,l);
	}
	vector<vector<double> > Ans(n+1,vector<double>(31,INF));

	priority_queue<Node> Q;
	Q.push(Node(s,0,0.0,s));
	while(!Q.empty()){
		Node t=Q.top(); Q.pop();
		if(Ans[t.now][t.speed]<=t.time) continue;		
//		cout<<t.now<<" "<<t.speed<<" "<<t.time<<endl;
		if(t.now==g && t.speed==1){printf("%.12lf\n", t.time );  return;}
		Ans[t.now][t.speed]=t.time;

		for(int i=0;i<=n;i++){
			if(i==t.before) continue;
			if(E[t.now][i].cost>0){
				if(E[t.now][i].limit>=t.speed && t.speed>=1)
					Q.push(Node(i,t.speed,t.time+E[t.now][i].cost/(double)t.speed,t.now));

				if(E[t.now][i].limit>=t.speed+1)
					Q.push(Node(i,t.speed+1,t.time+E[t.now][i].cost/(double)(t.speed+1.0),t.now));

				if(E[t.now][i].limit>=t.speed-1 && t.speed-1>=1)
					Q.push(Node(i,t.speed-1,t.time+E[t.now][i].cost/(double)(t.speed-1.0),t.now));
			}
		}
	}
	cout<<"unreachable"<<endl;

}

int main()
{
	while(cin>>n>>m && n!=0)
		solve();
	return 0;
}

Compiler output:
a.cc:77:8: error: redefinition of 'struct edge'
   77 | struct edge{
      |        ^~~~
a.cc:6:8: note: previous definition of 'struct edge'
    6 | struct edge{
      |        ^~~~
a.cc:86:8: error: redefinition of 'struct Node'
   86 | struct Node{
      |        ^~~~
a.cc:15:8: note: previous definition of 'struct Node'
   15 | struct Node{
      |        ^~~~
a.cc:94:6: error: redefinition of 'bool operator<(Node, Node)'
   94 | bool operator < (Node a,Node b){
      |      ^~~~~~~~
a.cc:23:6: note: 'bool operator<(Node, Node)' previously defined here
   23 | bool operator < (Node a,Node b){
      |      ^~~~~~~~
a.cc:98:5: error: redefinition of 'int n'
   98 | int n,m,s,g;
      |     ^
a.cc:27:5: note: 'int n' previously declared here
   27 | int n,m,s,g;
      |     ^
a.cc:98:7: error: redefinition of 'int m'
   98 | int n,m,s,g;
      |       ^
a.cc:27:7: note: 'int m' previously declared here
   27 | int n,m,s,g;
      |       ^
a.cc:98:9: error: redefinition of 'int s'
   98 | int n,m,s,g;
      |         ^
a.cc:27:9: note: 'int s' previously declared here
   27 | int n,m,s,g;
      |         ^
a.cc:98:11: error: redefinition of 'int g'
   98 | int n,m,s,g;
      |           ^
a.cc:27:11: note: 'int g' previously declared here
   27 | int n,m,s,g;
      |           ^
a.cc:100:6: error: redefinition of 'void solve()'
  100 | void solve(){
      |      ^~~~~
a.cc:29:6: note: 'void solve()' previously defined here
   29 | void solve(){
      |      ^~~~~
a.cc:138:5: error: redefinition of 'int main()'
  138 | int main()
      |     ^~~~
a.cc:66:5: note: 'int main()' previously defined here
   66 | int main()
      |     ^~~~