#include <iostream> #include <string.h> #include <stdio.h> #include <map> #define INF 1000000000 using namespace std; map<int,int> m; int graph[105][105]; int sum[105]; double total; int main() { int a,b,cnt; int kase =1; while(cin>>a) { cin>>b; if(a==0 && b==0) break; for(int i=1;i<101;i++) { sum[i]=0; for(int j=1;j<101;j++) { graph[i][j]=INF; if(i==j) graph[i][j]=0; } } cnt=1; m.clear(); m[a]=cnt; if(m[b]==0) { cnt+=1; m[b]=cnt; } graph[m[a]][m[b]]=1; while(cin>>a) { cin>>b; if(a==0 && b==0) break; if(m[a]==0) { cnt+=1; m[a]=cnt; } if(m[b]==0) { cnt+=1; m[b]=cnt; } graph[m[a]][m[b]]=1; } int len = m.size(); for(int k=1;k<=len;k++) { for(int i=1;i<=len;i++) { for(int j=1;j<=len;j++) { if(graph[i][j]>(graph[i][k]+graph[k][j])) graph[i][j] = (graph[i][k]+graph[k][j]); } } } total = 0; for(int i=1;i<=len;i++) { for(int j=1;j<=len;j++) { sum[i]+=graph[i][j]; } total+=sum[i]; } //cout<<"t = "<<total<<"\n"; //cout<<"len ="<<len*(len-1)<<"\n"; total/=(len*(len-1)); cout<<"Case "<<kase++<<": average length between pages = "; printf("%.3lf",total); cout<<" clicks\n"; } return 0; }