[ACM_图论] ZOJ 3708 [Density of Power Network 线路密度,a->b=b->a去重]
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
3
3 2
1 2
2 3
2 2
1 2
2 1
14 20
2 5 3 4 5 4 5 7 9 6 11 12 13 8 9 10 14 11 13 13
1 1 2 2 2 3 4 4 4 5 6 6 6 7 7 9 9 10 12 14
Sample Output
0.667
0.500
1.429
Author: WANG, Yelei
Contest: The 10th Zhejiang Provincial Collegiate Programming Contest
题目大意:每个样例第一行是公交车的数目与路线的数目,第二行是公交车起点,第三行是终点,从a->b与b->a是同一条路线,计算总路线与车辆数目的比值
解题思路:水题,不解释。
#include<iostream>
#include<algorithm>
#include<string.h>
#include<stdio.h>
#include<set>
using namespace std;
int main(){
int T;
cin>>T;
while(T--){
int N,M;
cin>>N>>M;
int start[],end[];
for(int i=;i<M;i++)
cin>>start[i];
for(int i=;i<M;i++)
cin>>end[i]; int curM=M;
for(int i=;i<M-;i++){
for(int j=i+;j<M;j++){
if((start[i]==start[j] && end[i]==end[j])
||(start[i]==end[j] && end[i]==start[j])){
curM--;
break;
}
}
} printf("%.3lf\n",curM/(1.0*N));
}return ; }
[ACM_图论] ZOJ 3708 [Density of Power Network 线路密度,a->b=b->a去重]的更多相关文章
- zoj 3708 Density of Power Network
/*看英文和图我头都大了,不过很简单的.*/ #include<string.h> #include<stdio.h> ][],q[],w[]; int main(int ar ...
- ZOJ Problem Set - 3708 Density of Power Network
http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3708 #include <stdio.h> #include ...
- Density of Power Network(ZOJ 3708)
Problem The vast power system is the most complicated man-made system and the greatest engineering i ...
- ZOJ3708:Density of Power Network
The vast power system is the most complicated man-made system and the greatest engineering innovatio ...
- POJ 1459 Power Network / HIT 1228 Power Network / UVAlive 2760 Power Network / ZOJ 1734 Power Network / FZU 1161 (网络流,最大流)
POJ 1459 Power Network / HIT 1228 Power Network / UVAlive 2760 Power Network / ZOJ 1734 Power Networ ...
- poj1459 Power Network (多源多汇最大流)
Description A power network consists of nodes (power stations, consumers and dispatchers) connected ...
- Power Network(网络流最大流 & dinic算法 + 优化)
Power Network Time Limit: 2000MS Memory Limit: 32768K Total Submissions: 24019 Accepted: 12540 D ...
- Power Network 分类: POJ 2015-07-29 13:55 3人阅读 评论(0) 收藏
Power Network Time Limit: 2000MS Memory Limit: 32768K Total Submissions: 24867 Accepted: 12958 Descr ...
- POJ1459 Power Network(网络最大流)
Power Network Time Limit: 2000MS Memory Limit: 32768K Total S ...
随机推荐
- jquery selector checkbox
$("#competencyList input:checkbox").on("click", function () { var checkedCompete ...
- [转]df命令
linux中df命令参数功能:检查文件系统的磁盘空间占用情况.可以利用该命令来获取硬盘被占用了多少空间,目前还剩下多少空间等信息. 语法:df [选项] 该命令各个选项的含义如下: -a 显示所有文件 ...
- SWFTools参数
CMD: d:\SWFTools>pdf2swf -o c:\2.swf -s flashversion=9 -s languagedir=c:\xpdf\xpdf-cinese-simplif ...
- hdu 2196 computer
Computer Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Su ...
- asp.net截取指定长度的字符串内容
/// <summary> /// 用于截取指定长度的字符串内容 /// </summary> /// <param name="sString"&g ...
- java 下载 断点续传
1 import java.io.BufferedInputStream; 2 import java.io.File; 3 import java.io.FileInputStream; 4 imp ...
- php 万能加密
function fue($hash,$times) { // Execute the encryption(s) as many times as the user wants for($i=$ti ...
- Echarts data数据为空时,显示“-”
{ name:'2007', type:'bar', data:["","",""]} 解决办法: 写成data:["" ...
- jQuery数组处理汇总
jQuery数组处理汇总 有段时间没写什么了, 打算把jquery中的比较常用的数组处理方法汇总一下 $.each(array, [callback])遍历,很常用 1 2 3 4 5 6 7 8 ...
- linux档案与文件的的压缩与打包
本文涉及的命令:gzip.zcat.bzip2.bzcat.tar.dump.restore.mkiosfs.cdrecord.dd.cpio. 概念: 几种基础压缩的概念: 计算机最小单位是字节,但 ...