http://www.lightoj.com/volume_showproblem.php?problem=1321

题意:每条边都有概率无法经过,但可以重新尝试,现给出成功率,传输次数和传输时间,求到达终点消耗时间最小的期望值的两倍。

思路:搞清楚题意后,就是个水题,暴力floyd求一下最大概率,再求下期望就好了。

/** @Date    : 2016-12-02-16.24
* @Author : Lweleth (SoungEarlf@gmail.com)
* @Link : https://github.com/
* @Version :
*/
#include <stdio.h>
#include <iostream>
#include <string.h>
#include <algorithm>
#include <utility>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <stack>
#include <queue>
//#include<bits/stdc++.h>
#define LL long long
#define PII pair<int ,int>
#define MP(x, y) make_pair((x),(y))
#define fi first
#define se second
#define PB(x) push_back((x))
#define MMG(x) memset((x), -1,sizeof(x))
#define MMF(x) memset((x),0,sizeof(x))
#define MMI(x) memset((x), INF, sizeof(x))
using namespace std; const int INF = 0x3f3f3f3f;
const int N = 1e5+2000; double mp[110][110]; void floyd(int n)
{
for(int k = 0; k < n; k++)
for(int i = 0; i < n; i++)
{
for(int j = 0; j < n; j++)
{
if(i == j || k == i || k == j)//注意判条件
continue;
mp[i][j] = max(mp[i][j], mp[i][k]*mp[k][j]);
mp[j][i] = mp[i][j];
}
}
} int main()
{
int T;
int cnt = 0;
cin >> T;
while(T--)
{
int n, m;
double s, k;
scanf("%d%d%lf%lf", &n, &m, &s, &k);
MMF(mp);
while(m--)
{
int v, u;
double p;
scanf("%d%d%lf", &v, &u, &p);
mp[v][u] = mp[u][v] = p / (double)100;
} floyd(n);
double ans = s * k * 2 / mp[0][n - 1];
printf("Case %d: %.10lf\n", ++cnt, ans);
}
return 0;
}

LightOJ 1321 - Sending Packets 简单最短路+期望的更多相关文章

  1. LightOJ - 1321 Sending Packets —— 概率期望

    题目链接:https://vjudge.net/problem/LightOJ-1321 1321 - Sending Packets    PDF (English) Statistics Foru ...

  2. Pairs Forming LCM (LightOJ - 1236)【简单数论】【质因数分解】【算术基本定理】(未完成)

    Pairs Forming LCM (LightOJ - 1236)[简单数论][质因数分解][算术基本定理](未完成) 标签: 入门讲座题解 数论 题目描述 Find the result of t ...

  3. Aladdin and the Flying Carpet (LightOJ - 1341)【简单数论】【算术基本定理】【分解质因数】

    Aladdin and the Flying Carpet (LightOJ - 1341)[简单数论][算术基本定理][分解质因数](未完成) 标签:入门讲座题解 数论 题目描述 It's said ...

  4. Sigma Function (LightOJ - 1336)【简单数论】【算术基本定理】【思维】

    Sigma Function (LightOJ - 1336)[简单数论][算术基本定理][思维] 标签: 入门讲座题解 数论 题目描述 Sigma function is an interestin ...

  5. Goldbach`s Conjecture(LightOJ - 1259)【简单数论】【筛法】

    Goldbach`s Conjecture(LightOJ - 1259)[简单数论][筛法] 标签: 入门讲座题解 数论 题目描述 Goldbach's conjecture is one of t ...

  6. Sending Packets LightOJ - 1321 (期望计算)

    题面: Alice and Bob are trying to communicate through the internet. Just assume that there are N route ...

  7. N - Tram - poj1847(简单最短路)

    题意:火车从一点开到另一点,轨道上有很多岔路口,每个路口都有好几个方向(火车能够选任意一个方向开),但是 默认的是 第一个指向的方向,所以如果要选择别的方向的话得 进行一次切换操作 ,给定一个起点一个 ...

  8. hdu2112(HDU Today 简单最短路)

    Problem Description 经过锦囊相助,海东集团终于度过了危机,从此,HDU的发展就一直顺风顺水,到了2050年,集团已经相当规模了,据说进入了钱江肉丝经济开发区500强.这时候,XHD ...

  9. 简单概率dp(期望)-zoj-3640-Help Me Escape

    题目链接: http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=4808 题目大意: 有n条路,选每条路的概率相等,初始能力值为f,每 ...

随机推荐

  1. SPOJ 8073 The area of the union of circles(计算几何の圆并)(CIRU)

    Description You are given N circles and expected to calculate the area of the union of the circles ! ...

  2. 实用的ES6特性

    1. 函数参数默认值 不使用ES6 为函数的参数设置默认值: function foo(height, color) { var height = height || 50; var color = ...

  3. Bus of Characters(栈和队列)

    In the Bus of Characters there are nn rows of seat, each having 22 seats. The width of both seats in ...

  4. lintcode-30-插入区间

    插入区间 给出一个 无重叠 的按照区间起始端点排序的区间列表. 在列表中插入一个新的区间,你要确保列表中的区间仍然有序且 不重叠 (如果有必要的话,可以合并区间). 样例 插入区间[2, 5] 到 [ ...

  5. centos7 下pycharm无法输入中文问题解决方案

    作者使用的pycharm是2017.2 在pycharm.sh脚本的如下行(大约在201行): # -------------------------------------------------- ...

  6. PHP查询网站

    1.w3school http://www.w3school.com.cn/php/ 2.PHP官网 http://php.net/manual/en/funcref.php 3.国内的类似w3csh ...

  7. 统计VS2013中有效行数

    将鼠标放在解决方案处,按下ctrl+shift+F b*[^:b#/]+.*$(带前面的using)^b*[^:b#/]+.*$

  8. 用c++读取文件夹中的所有文件名

    //头文件,注意要加stdafx.h和io.h等 #include "stdafx.h" #include <io.h> #include <vector> ...

  9. linux 装redmine

    看第一篇 https://www.cnblogs.com/iluzhiyong/p/redmine.html 看第二篇 http://blog.51yip.com/cloud/1874.html 基本 ...

  10. js alert()后进行跳转的方法

    如果alert()之后再进行跳转本页,按以下方法你将等不到alert(),浏览器就本身刷新本页面了 <script type="text/javascript"> al ...