【题意】现在有一些线索,每个线索被发现的概率p[i],如果线索i被知道,那么其他线索也可能会被知道,用vector<string> c给出,c[i][j]='Y'表示知道i这个线索,j这个线索能直接知道,问最终发现的线索个数的期望。

所有p[i]的和不是1...

求每个clue被选中的概率,由题意,如果知道第i个数,那么可以立即知道其他一些点,那么可以先用floyd,求出当知道结点i后应该知道哪些结点。

然后两重求反,1-(1-p[i1])(1-p[i2])...(1-p[ik])就是所求答案,其中选中i1,i2,...,ik中的任意一个都能选中i。

#include<cstdio>
#include<cstring>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<set>
#include<map>
#include<stack>
#include<vector>
#include<queue>
#include<string>
#include<sstream>
#define eps 1e-9
#define ALL(x) x.begin(),x.end()
#define INS(x) inserter(x,x.begin())
#define FOR(i,j,k) for(int i=j;i<=k;i++)
#define MAXN 1005
#define MAXM 40005
#define INF 0x3fffffff
using namespace std;
typedef long long LL;
int i,j,k,n,m,x,y,T,ans,big,cas,num;
bool flag;
double pa[MAXN];
class TheTips
{
public:
double solve(vector <string> c, vector <int> p)
{
int n=c.size();
for (k=;k<n;k++)
{
for (i=;i<n;i++)
{
for (j=;j<n;j++)
{
if (i==j || j==k || i==k) continue;
if (c[i][k]=='Y'&& c[k][j]=='Y') c[i][j]='Y';
}
}
} for (i=;i<n;i++) c[i][i]='Y'; for (i=;i<n;i++) pa[i]=;
//for (i=0;i<n;i++) cout<<c[i]<<endl; for (j=;j<n;j++)
{
for (i=;i<n;i++)
{
if (c[i][j]=='Y')
{
pa[j]*=-p[i]*0.01;
}
}
}
//for (i=0;i<n;i++) printf("%d %f\n",i,pa[i]); double ans=;
for (i=;i<n;i++)
{
ans+=-pa[i];
}
return ans; }
};

TCO 2015 Round 1B DIV1 500 概率题的更多相关文章

  1. TCO 2015 Round 2A DIV1

    ModModMod 傻逼数论 题意: 这是一道卖萌的题..给你一个取模序列$m$,令$f(x)=(\cdots (x\ mod\ m[0])\ mod m[1])\mod m[2]\cdots $,问 ...

  2. TCO 2016 Round 1B

    problem 250 Problem Statement Vasa likes to construct sequences of numbers. If you tell him a positi ...

  3. TopCoder SRM502 Div1 500 贪心 01背包

    原文链接https://www.cnblogs.com/zhouzhendong/p/SRM502-500.html SRM502 Div1 500 好题. 首先,如果已经确定了解决所有问题的优先级, ...

  4. [Codeforces Round #254 div1] C.DZY Loves Colors 【线段树】

    题目链接:CF Round #254 div1 C 题目分析 这道题目是要实现区间赋值的操作,同时还要根据区间中原先的值修改区间上的属性权值. 如果直接使用普通的线段树区间赋值的方法,当一个节点表示的 ...

  5. Codeforces Round #543 Div1题解(并不全)

    Codeforces Round #543 Div1题解 Codeforces A. Diana and Liana 给定一个长度为\(m\)的序列,你可以从中删去不超过\(m-n*k\)个元素,剩下 ...

  6. Codeforces Round #545 Div1 题解

    Codeforces Round #545 Div1 题解 来写题解啦QwQ 本来想上红的,结果没做出D.... A. Skyscrapers CF1137A 题意 给定一个\(n*m\)的网格,每个 ...

  7. Codeforces Round VK Cup 2015 - Round 1 (unofficial online mirror, Div. 1 only)E. The Art of Dealing with ATM 暴力出奇迹!

    VK Cup 2015 - Round 1 (unofficial online mirror, Div. 1 only)E. The Art of Dealing with ATM Time Lim ...

  8. 【前行&赛时总结】◇第4站&赛时9◇ CF Round 513 Div1+Div2

    ◇第4站&赛时9◇ CF Round 513 Div1+Div2 第一次在CF里涨Rating QWQ 深感不易……作blog以记之 ( ̄▽ ̄)" +Codeforces 的门为你打 ...

  9. Codeforces Round #378 (Div. 2) D题(data structure)解题报告

    题目地址 先简单的总结一下这次CF,前两道题非常的水,可是第一题又是因为自己想的不够周到而被Hack了一次(或许也应该感谢这个hack我的人,使我没有最后在赛后测试中WA).做到C题时看到题目情况非常 ...

随机推荐

  1. PHPCMS V9调用时间标签 |日期时间格式化

    PHPCMS V9 如何调用时间标签,下面分享常见的调用时间标签 |日期时间格式化  1.日期时间格式化显示: a标准型:{date('Y-m-d H:i:s', $rs['inputtime'])} ...

  2. Day8 面向对象(补充)

    私有字段 class Foo: def __init__(self, name): self.__name = name def f1(self): print(self.__name) class ...

  3. nopcommerce 二次开发

    http://www.cnblogs.com/nopcommerce-b2c/ http://www.nopchina.net/ 数据库结构 http://www.xcode.me/open/docu ...

  4. how to optimize javascript performance

    https://developers.google.com/speed/articles/optimizing-javascript http://developer.yahoo.com/perfor ...

  5. Tiling(递推+大数)

    Description In how many ways can you tile a 2xn rectangle by 2x1 or 2x2 tiles? Here is a sample tili ...

  6. sphinx插入代码

    示例的Python源代码或者交互界面都可以使用标准reST模块实现.在正常段落后面跟着 :: 开始,再加上适当缩进. 交互界面需包含提示及Python代码的输出. 交互界面没有特别的标记. 在最后一行 ...

  7. POJ-3468-A Simple Problem with Integers(区间更新,求和)-splay或线段树

    区间更新求和 主要用来练习splay树区间更新问题 //splay树的题解 // File Name: 3468-splay.cpp // Author: Zlbing // Created Time ...

  8. 线性代数(高斯消元):JSOI2008 球形空间产生器sphere

    JSOI2008 球形空间产生器sphere [题目描述] 有一个球形空间产生器能够在n维空间中产生一个坚硬的球体.现在,你被困在了这个n维球体中,你只知道球面上n+1个点的坐标,你需要以最快的速度确 ...

  9. 将汉字转化为拼音,正则表达式和得到汉字的Unicode编码

    一:上图,不清楚的看代码注解,很详细了 二:具体代码 窗体代码 using System; using System.Collections.Generic; using System.Compone ...

  10. Computer Vision Algorithm Implementations

    Participate in Reproducible Research General Image Processing OpenCV (C/C++ code, BSD lic) Image man ...