LightOj_1321 Sending Packets
题意:
给一个数据大小为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的更多相关文章
- LightOJ - 1321 Sending Packets —— 概率期望
题目链接:https://vjudge.net/problem/LightOJ-1321 1321 - Sending Packets PDF (English) Statistics Foru ...
- LightOJ 1321 - Sending Packets 简单最短路+期望
http://www.lightoj.com/volume_showproblem.php?problem=1321 题意:每条边都有概率无法经过,但可以重新尝试,现给出成功率,传输次数和传输时间,求 ...
- Sending Packets LightOJ - 1321 (期望计算)
题面: Alice and Bob are trying to communicate through the internet. Just assume that there are N route ...
- 给libpcap增加一个新的捕包方法
libpcap是一个网络数据包捕获函数库,功能非常强大,提供了系统独立的用户级别网络数据包捕获接口,Libpcap可以在绝大多数类unix 平台下工作.大多数网络监控软件都以它为基础,著名的tcpdu ...
- 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 ...
- Linux中的TUN/TAP设备
今天才发现这家伙...怎么讲...深以为耻.晚上的任务是加深对它的了解,就这么定了. 1. General questions.1.1 What is the TUN ? The TUN is Vi ...
- Nmap备忘单:从探索到漏洞利用(Part 2)
这是我们的第二期NMAP备忘单(第一期在此).基本上,我们将讨论一些高级NMAP扫描的技术,我们将进行一个中间人攻击(MITM).现在,游戏开始了. TCP SYN扫描 SYN扫描是默认的且最流行的扫 ...
- TCP keepalive overview
2. TCP keepalive overview In order to understand what TCP keepalive (which we will just call keepali ...
- 网络与RPC
网络与RPC 标签 : Java基础 Java为网络编程提供的java.net包封装了底层通信细节, 包含了大量的基础组件以及TCP/UDP协议的编程接口, 使得开发者可以专注于解决问题, 而不用关注 ...
随机推荐
- 基于x86架构的内核Demo的详细开发文档
http://hurlex.0xffffff.org/ 这里是hurlex这个基于x86架构的内核Demo的详细开发文档, 包含PDF文档和生成PDF的XeLaTex源码和文档每章节的阶段代码. 你可 ...
- ecto注册码
First name: Good Last name: Life Serial: ecto_at585-RP00-MP3F-VB8R-L82N-N0CC First Name: The Last ...
- How To Install Kernel 3.10 On Ubuntu, Linux Mint, Debian and Derivates
n this article I will show you how to install Linux Kernel 3.10 on Ubuntu 13.10 Saucy Salamander, Ub ...
- 文件处理-Directory类 (C#)
转http://skybirdzw.blog.163.com/blog/static/7257062620099751329403/ 文件处理-Directory类 (C#) Directory.Cr ...
- AWS 命令行界面 + Python 的 AWS 开发工具包 (Boto3)
安装AWS CLI $ pip install awscli 安装Boto3 $ pip install boto3 设置AWS CLI $ aws configure AWS Access Key ...
- Java中的编码问题
下面将侧重介绍java乱码是如何产生的.存在哪些乱码的情况.该如何从根本上解决乱码问题.各位随博主一起征服令人厌烦的java乱码问题吧!!! 一.Java编码转换过程 我们总是用一个java类文件和用 ...
- 使用modelsim仿真DDR3时编译出错的解决方法
Modelsim 10.1c release note sates as : Product Changes in 10.1c Release 10.1b introduced a new error ...
- volatile--共享数据必须保证可见性
在Effective Java中看到的,试了一下,有点意思,考查的知识点是volatile关键字. 下面这段代码,预期是打印it takes xxxx miliseconds. .但实际上,陷入了死循 ...
- java经验总结二:ORA-08103: 对象不再存在
问题发生的环境: 在springMvc+mybatis框架中,调用oracle的存储过程时,碰到的一个这样的异常: org.springframework.jdbc.UncategorizedSQLE ...
- scrapy抓取到中文,保存到json文件为unicode,如何解决.
http://scrapy-chs.readthedocs.org/zh_CN/latest/intro/overview.html 以上链接是很好的scrapy学些资料.感谢marchtea的翻译. ...