n fish, numbered from 1 to n , live in a lake. Every day right one pair of fish meet, and the probability of each other pair meeting is the same. If two fish with indexes i and j meet, the first will eat up the second with the probability a ij , and the second will eat up the first with the probability a ji  = 1 - a ij . The described process goes on until there are at least two fish in the lake. For each fish find out the probability that it will survive to be the last in the lake.-笔试面试资料

这是qklbishe.com第17175 篇笔试面试资料
提供答案分析,通过本文《n fish, numbered from 1 to n , live in a lake. Every day right one pair of fish meet, and the probability of each other pair meeting is the same. If two fish with indexes i and j meet, the first will eat up the second with the probability a ij , and the second will eat up the first with the probability a ji  = 1 - a ij . The described process goes on until there are at least two fish in the lake. For each fish find out the probability that it will survive to be the last in the lake.-笔试面试资料》可以理解其中的代码原理,这是一篇很好的求职学习资料
本站提供程序员计算机面试经验学习,笔试经验,包括字节跳动/头条,腾讯,阿里,美团,滴滴出行,网易,百度,京东,小米,华为,微软等互联网大厂真题学习背诵。

答案:

n fish, numbered from 1 to n , live in a lake. Every day right one pair of fish meet, and the probability of each other pair meeting is the same. If two fish with indexes i and j meet, the first will eat up the second with the probability a ij , and the second will eat up the first with the probability a ji  = 1 - a ij . The described process goes on until there are at least two fish in the lake. For each fish find out the probability that it will survive to be the last in the lake.

n     fish, numbered from 1  to      n    , live in a lake. Every day right one pair of fish meet, and   the probability of each other pair meeting is the same. If two fish   with indexes i and j meet, the first will eat up the second with the   probability      a            ij         , and the second will eat up the first with the probability          a            ji      = 1 - a            ij         . The described process goes on until there are at least two   fish in the lake. For each fish find out the probability that it will   survive to be the last in the lake. pipipapi
#include<bits/stdc++.h>  using namespace std;  const int N = 1<<19; const int M = 19;  int n; double f[N],g[M][M];  int count(int x){ 	int cnt = 0; 	while(x){ 		cnt += (x&1); 		x >>= 1; 	} 	return cnt; }  void solve(){ 	f[(1 << n) - 1] = 1; 	int tot = (1 << n) - 1; 	for(int i = tot-1; i ; i--){ 		int num = count(i) ; 		for(int j = 0; j < n; j++) 			if(!(i>>j&1)) 				for(int k = 0;k < n; k ++){ 					if(j == k) continue; 					if(i>>k&1) 						f[i] +=  1.0*f[i|(1<<j)]*g[k][j]/(num*(num+1)/2); 				} 	} }  void answer(){ 	for(int i = 0; i < n ; i ++ ) 		cout << fixed << setprecision(6) << f[(1<<i)] << " "; }  int main(){ 	cin >> n; 	for(int i = 0; i < n; i++) 		for(int j = 0; j < n ;j++) 			cin >> g[i][j]; 	solve(); 	answer(); 	return 0; }

今天 18:51:45 回复(0)

文章部分来自互联网,侵权联系删除
www.qklbishe.com

区块链毕设网(www.qklbishe.com)全网最靠谱的原创区块链毕设代做网站
部分资料来自网络,侵权联系删除!
资源收费仅为搬运整理打赏费用,用户自愿支付 !
qklbishe.com区块链毕设代做网专注|以太坊fabric-计算机|java|毕业设计|代做平台 » n fish, numbered from 1 to n , live in a lake. Every day right one pair of fish meet, and the probability of each other pair meeting is the same. If two fish with indexes i and j meet, the first will eat up the second with the probability a ij , and the second will eat up the first with the probability a ji  = 1 - a ij . The described process goes on until there are at least two fish in the lake. For each fish find out the probability that it will survive to be the last in the lake.-笔试面试资料

提供最优质的资源集合

立即查看 了解详情