题目链接

题意:

  给一个数据大小为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. QT QSqlQuery QSqlQueryModel

      SQL执行操作 QSqlQuery提供了对数据库记录的Select.Insert.Update.Delete操作. SELECT操作: QSqlQuery query; query.exec(&q ...

  2. eclipse 中修改 M2_REPO的值--转载

    从eclipse中增加了maven2的插件之后,maven默认的本地库的路径是${user}/.m2/repository/下,一般windows用户的操作系统都安装在C盘,所以这个目录 下的jar包 ...

  3. Bash String Manipulation Examples – Length, Substring, Find and Replace--reference

    In bash shell, when you use a dollar sign followed by a variable name, shell expands the variable wi ...

  4. 【Android】 onSaveInstanceState()恢复数据

    onSaveInstanceState()方法会携带一个 Bundle 类型的参数,Bundle 提供了一系列的方法用于保存数据,比如可以使用 putString()方法保存字符串,使用 putInt ...

  5. [置顶] Datalist嵌套datalist,页面传值,加密,数据绑定

    <asp:DataList ID="dlMajor" runat="server" CssClass="dllist" OnItemD ...

  6. Spring 3.0 + Atomikos构建jta分布式事务

    Spring3.0已经不再支持jtom了,不过我们可以用第三方开源软件atomikos(http://www.atomikos.com/)来实现.Atomikos是目前在分布式事务管理中做得相当不错的 ...

  7. CentOS6.4安装ati显卡驱动

    台式机安装CentOS 6.4 x86_64位  集成显卡ati4290 CentOS的release notes上: The proprietary drivers for older AMD ( ...

  8. Maven笔记(二)仓库

    1.仓库布局 任何一个构件都有其唯一的坐标,根据这个坐标可以定义其在仓库中的唯一存储路径,这就是Maven的仓库布局方式 路径与坐标的对应关系为:groupId/artifactId/version/ ...

  9. 用正则表达式解析XML

    import java.util.regex.*; import java.util.*; /** * * <p>Title: Document</p> * * <p&g ...

  10. swift入门-day01

    Swift 简介 简介 Swift 语言由苹果公司在 2014 年推出,用来撰写 OS X 和 iOS 应用程序 2014 年,在 Apple WWDC 发布 历史 2010 年 7 月,苹果开发者工 ...