Density of Power Network
来源:互联网 发布:php读取excel数据 编辑:程序博客网 时间:2024/05/19 01:12
Description
The vast power system is the most complicated man-made system and the greatest engineering innovation in the 20th century. The following diagram shows a typical 14 bus power system. In real world, the power system may contains hundreds of buses and thousands of transmission lines.
Network topology analysis had long been a hot topic in the research of power system. And network density is one key index representing the robustness of power system. And you are asked to implement a procedure to calculate the network density of power system.
The network density is defined as the ratio between number of transmission lines and the number of buses. Please note that if two or more transmission lines connecting the same pair of buses, only one would be counted in the topology analysis.
Input
The first line contains a single integer T (T ≤ 1000), indicating there are T cases in total.
Each case begins with two integers N and M (2 ≤ N, M ≤ 500) in the first line, representing the number of buses and the number of transmission lines in the power system. Each Bus would be numbered from 1 to N.
The second line contains the list of start bus number of the transmission lines, separated by spaces.
The third line contains the list of corresponding end bus number of the transmission lines, separated by spaces. The end bus number of the transmission lines would not be the same as the start bus number.
Output
Output the network density of the power system in a single line, as defined in above. The answer should round to 3 digits after decimal point.
Sample Input
33 21 22 32 21 22 114 202 5 3 4 5 4 5 7 9 6 11 12 13 8 9 10 14 11 13 131 1 2 2 2 3 4 4 4 5 6 6 6 7 7 9 9 10 12 14
Sample Output
0.6670.5001.429
#include<stdio.h>#include<string.h>int main(){int n1;scanf("%d",&n1);while(n1--){ int i,j,a[10000],b[10000]; double c,p,n,m; c=p=0; scanf("%lf%lf",&n,&m); for(i=0;i<m;i++) scanf("%d",&a[i]); for(i=0;i<m;i++) { scanf("%d",&b[i]); if(a[i]==b[i])c++; } for(i=0;i<m;i++) for(j=i+1;j<m;j++) if(((a[i]==b[j]&&a[j]==b[i])||(a[i]==a[j]&&b[i]==b[j]))&&b[j]>0) { a[j]=-1; b[j]=-1; } for(i=0;i<m;i++) if(a[i]>0)p++; printf("%.3f\n",(p-c)/n);}}
- Density of Power Network
- Density of Power Network
- Density of Power Network
- ZOJ3708:Density of Power Network
- zoj 3708 Density of Power Network
- zju 3708 Density of Power Network
- ZOJ 3708 Density of Power Network
- ZOJ 3708 Density of Power Network
- ZOJ 3708 Density of Power Network
- ZOJ 3708Density of Power Network(图论)
- ZOJ 3708Density of Power Network
- ZOJ 3708 Density of Power Network (水题)
- ZOJ-3708-Density of Power Network
- ZOJ3708 Density of Power Network(水题)
- Density of Power Network ZOJ 3708
- prepare for the provincial time --10.2--Density of Power Network
- zoj 3708 Density of Power Network(数学啊)
- ZOJ 3708 Density of Power Network(水题)
- poj 2935 Basic Wall Maze
- 1015.还是A + B
- eclipse安装SVN插件的两种方法
- jqGrid编辑—公共规则【附视频、ppt、源码】
- container_of 用法解析
- Density of Power Network
- 记一次内存泄漏调试(memory leak)-Driver Monkey
- 条码生成与打印
- 最佳HTML5应用开发工具推荐
- Hard to Play
- jqGrid编辑—单元格编辑【附视频、ppt、源码】
- Java Beans
- 数据结构-栈和队列
- viewgroup scrollTo、scrollBy、getScrollX、getScrollY这4个方法的含义