zoj 3708 Density of Power Network
来源:互联网 发布:淘宝扫码海报图片 编辑:程序博客网 时间:2024/05/05 10:32
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 areT 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 toN.
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
Author: WANG, Yelei
Contest: The 10th Zhejiang Provincial Collegiate Programming Contest
开始被题目吓懵了。其实是道超级水题。
就是用电线数除电站数。不过两电站电线只算一根。
#include <stdio.h>#include<string.h>int s[550],e[550],state[550][550];//s记录开始的总电站。e记录结束的总电站//state记录两电站是否已有电线。因为两电站电线只算一根int main(){ int t,m,n,i; double sum; scanf("%d",&t); while(t--) { memset(state,0,sizeof state); scanf("%d%d",&n,&m); sum=0; for(i=1;i<=m;i++) scanf("%d",&s[i]); for(i=1;i<=m;i++) scanf("%d",&e[i]); for(i=1;i<=m;i++) { if(!state[s[i]][e[i]]) { sum++; state[s[i]][e[i]]=1; state[e[i]][s[i]]=1; } } printf("%.3lf\n",sum/n);//计算电线密度 } return 0;}
- zoj 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
- Density of Power Network ZOJ 3708
- zoj 3708 Density of Power Network(数学啊)
- ZOJ 3708 Density of Power Network(水题)
- ZOJ-3708-Density of Power Network【10th浙江省赛】
- ZOJ 3708 Density of Power Network(水题,图论)
- Density of Power Network
- Density of Power Network
- Density of Power Network
- zju 3708 Density of Power Network
- ZOJ3708:Density of Power Network
- MyEclipse 里面的工程,改了名字之后,在apache里面更新不了 这个怎么解决
- 响应式网页设计
- Zend Framework: The requested URL /newposter was not found on this server.
- uva 10795 - A Different Task(递推,3级)
- Yii cookie 使用
- zoj 3708 Density of Power Network
- 关于IP地址的几个函数
- linux 编译代码
- nginx端口监听队列长度
- java反射应用——从Class类中获取信息
- InstallShield 常用常量
- Effective C++
- java.lang.OutOfMemoryError: Java heap space 解决方法
- readv/writev 函数