将整体期望分成部分期望来做。
F. network
题目描述
A social network is a social structure made up of a set of social actors (such as individuals or organizations) and a set of the relationships between these actors. In simple cases, we may represent people as nodes in a graph, and if two people are friends, then an edge occurs between two nodes.
There are many interesting properties in a social network. Recently, we are researching on the SocialButterfly. A social butterfly should satisfy the following conditions:
A simple social network,where C knows everyone but D knows just C.
Now we have already had several networks in our database, but since the data only contain nodes and edges, we don't know whether a node represents a male or a female. We are interested, that if there are equal probabilities for a node to be male and female (each with 1/2 probability).A node is a social butterfly if and only if this node is a female and connects with at least K males.What will be the expectation of number of social butterflies in the network?
输入格式
The number of test cases T(T≤104) will occur in the first line of input.
For each test case:
The first line contains the number of nodes N(1≤N≤30)and the parameter K (0 <= K < N))
Then an N×Nmatrix G followed, where Gij=1 denotes j as a friend of i, otherwise Gij=0. Here, it's always satisfied that Gii=0and Gij=Gji for all 1≤i,j≤N.
输出格式
For each test case, output the expectation of number of social butterflies in 3 decimals.
##Hint
In the first sample, there are totally 4 cases: {Female, Female}, {Female,
Male},{Male, Female} and {Male, Male}, whose number of social butterflies
are respectively 0, 1, 1, 0. Hence, the expectation should be
输入样例
2
2 1
0 1
1 0
3 1
0 1 1
1 0 1
1 1 0
输出样例
0.500
1.125
//
// main.cpp
// 160323.F
//
// Created by 陈加寿 on 16/3/25.
// Copyright © 2016年 chenhuan001. All rights reserved.
// #include <iostream>
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <math.h>
using namespace std;
#define N 31 int mat[N][N];
double C[N][N]; int main() {
C[][]=;
for(int i=;i<=;i++)
{
C[i][]=;
for(int j=;j<=i;j++)
{
C[i][j] = C[i-][j-]+C[i-][j];
}
} int T;
cin>>T;
while(T--)
{
int n,k;
scanf("%d%d",&n,&k);
for(int i=;i<n;i++)
for(int j=;j<n;j++)
scanf("%d",&mat[i][j]);
double ans=;
for(int i=;i<n;i++)
{
int cnt=;
for(int j=;j<n;j++)
{
cnt+=mat[i][j];
}
double tmp=;
for(int j=k;j<=cnt;j++)
tmp += C[cnt][j];
tmp = tmp/pow(2.0,cnt);
tmp *= 0.5;
ans += tmp;
}
printf("%.3lf\n",ans);
}
return ;
}
线性期望(BUPT2015校赛.F)的更多相关文章
-
校赛F
问题描述 例如对于数列[1 2 3 4 5 6],排序后变为[6 1 5 2 4 3].换句话说,对于一个有序递增的序列a1, a2, a3, ……, an,排序后为an, a1, an-1, a2, ...
-
校赛F 比比谁更快(线段树)
http://acm.cug.edu.cn/JudgeOnline/problem.php?cid=1153&pid=5 题意:给你一个字符串,各两个操作: ch=0,[l,r]降序 ch=1 ...
-
xdu2017校赛F
Problem F Dogs of Qwordance Senior Backend R&D Engineers 问题描述 那年夏天,锘爷和杰师傅漫步在知春公园的小道上.他们的妻子.孩子牵 着 ...
-
浙江理工2015.12校赛-F Landlocked
Landlocked Time Limit: 5 Sec Memory Limit: 128 MB Submit: 288 Solved: 39 Description Canada is not a ...
-
上海高校金马五校赛 F题:1 + 2 = 3?
链接:https://www.nowcoder.com/acm/contest/91/F来源:牛客网 时间限制:C/C++ 1秒,其他语言2秒 空间限制:C/C++ 131072K,其他语言26214 ...
-
广州工业大学2016校赛 F 我是好人4 dfs+容斥
Problem F: 我是好人4 Description 众所周知,我是好人!所以不会出太难的题,题意很简单 给你n个数,问你1000000000(含1e9)以内有多少个正整数不是这n个数任意一个的倍 ...
-
北邮校赛 F. Gabriel&#39;s Pocket Money(树状数组)
F. Gabriel's Pocket Money 2017- BUPT Collegiate Programming Contest - sync 时间限制 2000 ms 内存限制 65536 K ...
-
2018年东北农业大学春季校赛 F wyh的集合【思维】
链接:https://www.nowcoder.com/acm/contest/93/F来源:牛客网 题目描述 你们wyh学长给你n个点,让你分成2个集合,然后让你将这n个点进行两两连接在一起,连接规 ...
-
西交校赛 F. GZP and Poker
F. GZP and Poker GZP often plays games with his friends.Today they went to a board game.There are n ...
随机推荐
-
jquery-uploadify 上传
先从官网下载插件 http://www.uploadify.com/ 引入之后.... html.................... <!-- 上传 --> <div id=&q ...
-
[Tool] 使用StyleCop验证命名规则
[Tool] 使用StyleCop验证命名规则 前言 微软的MSDN上,有提供了一份微软的命名方针,指引开发人员去建立风格一致的程序代码. http://msdn.microsoft.com/zh-t ...
-
Android应用程序签名详解 简介
转自: http://blog.csdn.net/lyq8479/article/details/6401093 本文主要讲解Android应用程序签名相关的理论知识,包括:什么是签名.为什么要给应用 ...
-
hmmer 使用(转载)
hmmer 使用 » 转载文章请注明,转载自:博耘生物 » <hmmer的安装与使用> » 原文链接:http://boyun.sh.cn/bio/?p=1753 从功能基因研究的角度 ...
-
(转载)一句简单命令重启nginx - [nginx]
(转载)http://iambin.blogbus.com/logs/62429223.html 经常需要重启nginx,但网上的很多教程都需要繁琐的启动脚本,远不如apache的重启命令那么简单. ...
-
maven依赖范围
Scope: Compile:编译依赖,默认就是compile,在编译.测试.运行都有效 Test:测试依赖,仅测试有效 例如Junit Provided:已提供依赖范围.编译.测试有效,运行时候无效 ...
-
在linux环境下编译运行OpenCV程序的两种方法
原来以为在Ubuntu下安装好了OpenCV之后,自己写个简单的程序应该很容易吧,但是呢,就是为了编译一个简单的显示图片的程序我都快被弄崩溃了. 在谷歌和上*查看相关问题解答之 ...
-
JS 面向对象 ~ 创建对象的 9 种方式
一.创建对象的几种方式 1.通过字面量创建 var obj = {}; 这种写法相当于: var obj = new Object(); 缺点:使用同一个接口创建很多单个对象,会产生大量重复代码 2. ...
-
解决编译安装php时报错:Please reinstall the iconv library
编译安装php7时报错“Please reinstall the iconv library”,也就是让重新安装iconv库.但yum安装又提示“No package libiconv availab ...
-
【原创】Linux环境下的图形系统和AMD R600显卡编程(2)——Framebuffer、DRM、EXA和Mesa简介【转】
转自:http://www.cnblogs.com/shoemaker/p/linux_graphics02.html 1. Framebuffer Framebuffer驱动提供基本的显示,fram ...