日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

线性期望(BUPT2015校赛.F)

發布時間:2023/12/13 编程问答 28 豆豆
生活随笔 收集整理的這篇文章主要介紹了 线性期望(BUPT2015校赛.F) 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

將整體期望分成部分期望來做。

F. network?

時間限制?3000 ms?內存限制?65536 KB

題目描述

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(T104)?will occur in the first line of?input.

For each test case:

The first line contains the number of nodes?N(1N30)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?1i,jN.

輸出格式

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

?

E=14×0+14×1+14×1+14×0=12

?

輸入樣例

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 31int mat[N][N]; double C[N][N];int main() {C[0][0]=1;for(int i=1;i<=30;i++){C[i][0]=1;for(int j=1;j<=i;j++){C[i][j] = C[i-1][j-1]+C[i-1][j];}}int T;cin>>T;while(T--){int n,k;scanf("%d%d",&n,&k);for(int i=0;i<n;i++)for(int j=0;j<n;j++)scanf("%d",&mat[i][j]);double ans=0;for(int i=0;i<n;i++){int cnt=0;for(int j=0;j<n;j++){cnt+=mat[i][j];}double tmp=0;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 0; }

?

?

轉載于:https://www.cnblogs.com/chenhuan001/p/5319838.html

總結

以上是生活随笔為你收集整理的线性期望(BUPT2015校赛.F)的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。