zoj 3708 Density of Power Network(数学啊)
来源:互联网 发布:唐山的软件代理商 编辑:程序博客网 时间:2024/05/16 05:06
题目链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3708
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
Author: WANG, Yelei
Contest: The 10th Zhejiang Provincial Collegiate Programming Contest
题意:
寻找不同的公交路线输! 注意a------b和b-----a是同一条!
代码如下:
#include <cstdio>#include <cstdlib>#include <cstring>#include <climits>#include <cctype>#include <iostream>#include <algorithm>#include <cmath>#include <string>using namespace std;int a[777],b[777];int mp[777][777];int main(){int t,m,n,i,j;cin>>t;while(t--){memset(mp,0,sizeof(mp));cin>>n>>m;for( i=0;i<m;i++){cin>>a[i];}for( i=0;i<m;i++){cin>>b[i];}for(i=0;i<m;i++){mp[a[i]][b[i]]=1;mp[b[i]][a[i]]=1;}int ans=0;for(i=1;i<=n;i++){for(j=i+1;j<=n;j++) {if(mp[i][j]){ans++;}}}printf("%.3lf\n",ans*1.0/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 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浙江省赛】
- Density of Power Network
- Density of Power Network
- Density of Power Network
- zju 3708 Density of Power Network
- ZOJ3708:Density of Power Network
- Android开发之android_apk 在线安装(源代码分享)
- linux系统IP改变后oracle监听无法启动
- 字符串倒序输出
- Android Camera 照相机屏幕旋转问题
- NewSQL初了解
- zoj 3708 Density of Power Network(数学啊)
- 中大-复试-2012-编程题二
- YII中You are not authorized to perform this action的解决方法
- C# 可访问性不一致
- js实现页面跳转的几种方式
- 再用Sqlite3 之学习新解,新感悟
- 【cocos2dx-3.0beta-制作flappybird】我才不会告诉你我硬盘的秘密呢—游戏存储的实现
- ExtJS4.2学习(五)表格渲染与复选框
- Hadoop2 上HDFS HA 搭建过程