题目链接

题意:

  给一个数据大小为S的数据包, 每一次发送需要K秒(单向),现在要从节点0 发送到节点 n-1。

  其中有n - 1条路径, 每条路径都有一个传输成功率。

  问传输成功所需最小时间的期望。

思路:

  最小时间的期望, 即最大的传输成功率, 最小的传输次数, 即只传输成功一次所需要的时间的期望。

  利用dijkstra or 中途相遇法进行求解从节点0到节点n-1的最大成功率。

  设其为p。

  我们所要求的是传输成功一次需要的次数的期望, 这满足几何分布, so, E = 1 / p。

  所以,ans = E * 2 * K * S

代码:

  

 #include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <ctime>
#include <set>
#include <map>
#include <list>
#include <queue>
#include <string>
#include <vector>
#include <fstream>
#include <iterator>
#include <iostream>
#include <algorithm>
using namespace std;
#define LL long long
#define INF 0x3f3f3f3f
#define MOD 1000000007
#define eps 1e-6
#define MAXN 110
#define MAXM 100
#define dd cout<<"debug"<<endl
#define pa {system("pause");}
#define p(x) printf("%d\n", x)
#define pd(x) printf("%.7lf\n", x)
#define k(x) printf("Case %d: ", ++x)
#define s(x) scanf("%d", &x)
#define sd(x) scanf("%lf", &x)
#define mes(x, d) memset(x, d, sizeof(x))
#define do(i, x) for(i = 0; i < x; i ++)
#define dod(i, x, l) for(i = x; i >= l; i --)
#define doe(i, x) for(i = 1; i <= x; i ++)
int n, m, s, k;
int kcase = ;
double f[MAXN][MAXN];
void solve()
{
for(int i = ; i < n; i ++)
f[i][i] = 1.0;
for(int t = ; t < n; t ++)
for(int i = ; i < n; i ++)
for(int j = ; j < n; j ++)
f[i][j] = max(f[i][j], f[i][t] * f[t][j]);
double ans = f[][n-];
double ex = (1.0 / ans) * (2.0 * k * s);
printf("Case %d: %.7lf\n", ++ kcase, ex);
} int main()
{
int T;
scanf("%d", &T);
while(T --)
{
scanf("%d %d %d %d", &n, &m, &s, &k);
int u, v, p;
for(int i = ; i < n; i ++)
for(int j = ; j < n; j ++)
f[i][j] = 0.0;
for(int i = ; i < m; i ++)
{
scanf("%d %d %d", &u, &v, &p);
f[u][v] = f[v][u] = p / 100.0;
}
solve();
}
return ;
}

LightOj_1321 Sending Packets的更多相关文章

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

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

  2. LightOJ 1321 - Sending Packets 简单最短路+期望

    http://www.lightoj.com/volume_showproblem.php?problem=1321 题意:每条边都有概率无法经过,但可以重新尝试,现给出成功率,传输次数和传输时间,求 ...

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

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

  4. 给libpcap增加一个新的捕包方法

    libpcap是一个网络数据包捕获函数库,功能非常强大,提供了系统独立的用户级别网络数据包捕获接口,Libpcap可以在绝大多数类unix 平台下工作.大多数网络监控软件都以它为基础,著名的tcpdu ...

  5. Overview and Evaluation of Bluetooth Low Energy: An Emerging Low-Power Wireless Technology

    转自:http://www.mdpi.com/1424-8220/12/9/11734/htm Sensors 2012, 12(9), 11734-11753; doi:10.3390/s12091 ...

  6. Linux中的TUN/TAP设备

    今天才发现这家伙...怎么讲...深以为耻.晚上的任务是加深对它的了解,就这么定了. 1. General questions.1.1 What is the TUN ?  The TUN is Vi ...

  7. Nmap备忘单:从探索到漏洞利用(Part 2)

    这是我们的第二期NMAP备忘单(第一期在此).基本上,我们将讨论一些高级NMAP扫描的技术,我们将进行一个中间人攻击(MITM).现在,游戏开始了. TCP SYN扫描 SYN扫描是默认的且最流行的扫 ...

  8. TCP keepalive overview

    2. TCP keepalive overview In order to understand what TCP keepalive (which we will just call keepali ...

  9. 网络与RPC

    网络与RPC 标签 : Java基础 Java为网络编程提供的java.net包封装了底层通信细节, 包含了大量的基础组件以及TCP/UDP协议的编程接口, 使得开发者可以专注于解决问题, 而不用关注 ...

随机推荐

  1. linux内存管理解析1----linux物理,线性内存布局及页表的初始化

    主要议题: 1分页,分段模式及实模式 2Linux分页 3linux内存线性地址空间布局及物理内存空间布局 4linux页表初始化及代码解析 1.1.1内存寻址和保护模式 在X86平台上,内存控制单元 ...

  2. JS火狐与IE的差别

    function isIE(){ //ie? ) return true; else return false; } if(!isIE()){ //firefox innerText define H ...

  3. iOS 并行编程:Thread

    1 创建线程 1.1 NSThread       使用 NSThread 来创建线程有两个可以使用的方法: 1) 使用 detachNewThreadSelector:toTarget:withOb ...

  4. Linux关闭防火墙、SELinux

    使用root权限: Linux关闭防火墙: 1. chkconfig –list|grep iptables 2. chkconfig iptables off 永久关闭防火墙 3. chkconfi ...

  5. mysql中查询某字段所在的表方法

    select TABLE_NAME from information_schema.COLUMNS where COLUMN_NAME = 'type'

  6. CentOS 6.6 yum源完全配置

    原文地址 http://blog.csdn.net/halazi100/article/details/41311837 一 yum 简介 yum,是"Yellow dog Updater, ...

  7. <input> 标签

    HTML5 中的新属性.   属性 值 描述 accept mime_type 规定通过文件上传来提交的文件的类型. align left right top middle bottom 不赞成使用. ...

  8. zigbee

    IEEE802.15.4定义了两种器件:全功能器件(FFD,Full-FunctionDevice),和简化功能器件(RFD,Reduced-functionDevice) 协调器:(coordina ...

  9. NFC标签

    2.4 NFC标签 NFC标签(以下也称tag)是一种带有NFC电路和天线的钱币大小的电子标签,见图2.1,小容量的标签售价约1元左右一枚. 基本标签类型有四种,以1至4来标识,各有不同的格式与容量. ...

  10. 学习笔记_Java_day13_三层的HelloWorld程序(15)--不错,整体三层架构学习

    分三层写:养成一个架构的习惯,如何编写一个大型网站 DAO数据层 service业务层 servlet web表述层