解题思路:
注意事项:
参考代码:
package Year_2017;
import java.util.Scanner;
public class 观光铁路 {
private static int n,m;
private static int [] arr ;
private static int [] degree ;
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
n = sc.nextInt();
m =sc.nextInt();
degree = new int [n];
arr = new int [n];
for(int i=0;i<m;i++) {
//记录各个城市的满意度
degree[sc.nextInt() - 1] ++;
degree[sc.nextInt() - 1] ++;
}
sc.close();
double totalDegree = 0;
for(int i=0;i<n;i++) {
totalDegree+=degree[i];
}
//===================================================================================
for(int i=0;i<n;i++) {
System.out.println(String.format("%.12f", totalDegree/degree[i]));
}
}
}
0.0分
1 人评分