[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 ...
随机推荐
- SVM1 线性SVM
一.Linear Support Vector Machine 接下来的讨论假设数据都是线性可分的. 1.1 SVM的引入:增大对测量误差的容忍度 假设有训练数据和分类曲线如下图所示: 很明显,三个分 ...
- 安装mysql5.5时候的报错解决办法:
每次安装mysql5.5的时候总会报出一下错误: -- Could NOT find OpenSSL (missing: OPENSSL_LIBRARIES OPENSSL_INCLUDE_DIR) ...
- Selenium2+python自动化10-登录案例
前言 前面几篇都是讲一些基础的定位方法,没具体的案例,小伙伴看起来比较枯燥,有不少小伙伴给小编提建议以后多出一些具体的案例.本篇就是拿部落论坛作为测试项目,写一个简单的登录测试脚本. 在写登录脚本的时 ...
- LeetCode.4 两个有序数组的中位数问题
这道题是那种典型的有显而易见的解法, 但是想要达到较优的时间复杂度的话就不是这么好做的题目. 我来说说我自己的思考过程 : 首先最先想到的是 O(m + n) 的解法, 也就是利用归并排序的归并将两个 ...
- 更改Windows系统时间同步频率【windows 7,windows 8,win10】
Windows系统默认的时间同步间隔是7天,如果我们需要修改同步的时间间隔(同步频率),我们可以通过修改注册表来手动修改它的自动同步间隔以提高同步次数,保证时钟的精度,windows7,Windows ...
- SMTP的相关命令
SMTP是Simple Mail Transfer Protocol的简写. 邮件是日常工作.生活中不能缺少的一个工具,下面是邮件收发的流程. Image 邮件的发送,主要是通过SMTP协议来实现的. ...
- POJ 2175 Evacuation Plan 费用流 负圈定理
题目给了一个满足最大流的残量网络,判断是否费用最小. 如果残量网络中存在费用负圈,那么不是最优,在这个圈上增广,增广1的流量就行了. 1.SPFA中某个点入队超过n次,说明存在负环,但是这个点不一定在 ...
- 【erlang】IPv6格式转IPv4
erlang里面的httpd模块保存的http请求头里面,其中remote_addr 保存的是IPv6的格式. 即使是IPv4,也会用IPv6的格式来保存.如 {remote_addr, " ...
- spider
from lxml import etreeimport requestsdef getHtml(html): novelcontent = requests.get(html).content re ...
- Android -- The Manifest File
Before the Android system can start an app component, the system must know that the component exists ...