有关图的密度的规律
来源:互联网 发布:网络泰迪含义 编辑:程序博客网 时间:2024/04/28 19:20
题目是这样的:
Description:
Input
The first line contains two space-separated integers n (1 ≤ n ≤ 500), . Integer n represents the number of nodes of the graph G, m represents the number of edges.
The second line contains n space-separated integers xi (1 ≤ xi ≤ 106), where xi represents the value of the i-th node. Consider the graph nodes are numbered from 1 to n.
Each of the next m lines contains three space-separated integers ai, bi, ci (1 ≤ ai < bi ≤ n; 1 ≤ ci ≤ 103), denoting an edge between node ai and bi with value ci. The graph won’t contain multiple edges.
Output
Output a real number denoting the answer, with an absolute or relative error of at most 10 ^- 9.
Hint
In the first sample, you can only choose an empty subgraph, or the subgraph containing only node 1.
In the second sample, choosing the whole graph is optimal.
解题的思路来自:
所以只需找到两个点中密度最大的即可!
代码如下:
#include <iostream>#include <cstdio>using namespace std;int a[505];int main(){ int n,m; int n1,n2; double max=0; int v; cin>>n>>m; for(int i=1;i<=n;i++) { scanf("%d",&a[i]); } if(n==1) { cout<<0.000000000000000<<endl; return 0; } for(int j=0;j<m;j++) { cin>>n1>>n2>>v; double n3= (double)(a[n1]+a[n2])/v; if(n3>max) { max=n3; } } printf("%.15lf",max); return 0;}
仅代表个人观点,欢迎交流探讨,勿喷~~~
PhotoBy:WLOP
http://weibo.com/wlop
- 有关图的密度的规律
- 人群密度估计 密度图的产生
- seo有关的关键字密度与网站排名
- 密度的逻辑
- 像素密度的计算
- 手机屏幕的密度分析
- 基于卷积的密度统计(一)密度图的生成
- 关于页面关键词的密度
- 基于密度的聚类
- 软件缺陷密度的计算方法
- 基于密度的聚类
- Android系统密度的修改
- 谈谈Android的密度独立性
- 图片的密度与屏幕
- 计算手机的像素密度
- 基于密度的聚类
- 基于密度的聚类
- 获取手机的屏幕密度
- MFC下CSocket编程详解
- 欢迎使用CSDN-markdown编辑器
- unity 集成 RenderDoc 调试shader的方法
- Android TV磁贴类app自动化框架二次改造(基于UiAutomator)
- static学习
- 有关图的密度的规律
- Android Looper详解
- 搬果子——优先队列
- HDU 4248 A Famous Stone Collector(DP + 组合数)
- OpenCV简介
- UIView的init调用
- HDU 1175 连连看
- ECharts-Java使用Java快速开发ECharts图表
- OpenCV杂记03---Scalar,row,col,cout