ss请cc来家里钓鱼,鱼塘可划分为n*m的格子,每个格子有不同的概率钓上鱼,cc一直在坐标(x,y)的格子钓鱼,而ss每分钟随机钓一个格子。问t分钟后他们谁至少钓到一条鱼的概率大?为多少?

include "stdafx.h"

include

include

include<math.h>

include

using namespace std;

int main()
{
int n,m, x, y, t;
while (cin>>n>>m>>x>>y>>t)
{
vector<vector> pVec;
for (int i = 0; i < n; i++)
{
vector vec;
for (int j = 0; j < m ; j++)
{
float p;
cin >> p;
// cout << "内层循环" << endl;
vec.push_back(p);
}
pVec.push_back(vec);
}

float ccP = 1-pow((1-pVec[x-1][y-1]),(double)t);
float ssP = 0.0;
int num = 0;
for (int x = 0; x < n; x++)
{
for (int y = 0; y < m; y++)
{
ssP = ssP+ pVec[x][y ];

}
}

ssP = ssP/n/m;
ssP = 1 - pow((1 -ssP), (double)t);

//设置输出标志

ssP = ssP * 100;
ccP = ccP * 100;
int sp = ssP;
int cp = ccP;
ssP = sp / 100;
ccP = cp / 100;

cout << setiosflags(ios::fixed);
if (ssP >ccP)
{
cout << "ss" << endl;
cout << setprecision(2) << ssP << endl;
}
else if (ssP <ccP)
{
cout << "cc" << endl;
cout << setprecision(2) << ccP << endl;
}
else
{
cout << "equal" << endl;
cout << setprecision(2)<<ccP << endl;
}

}

return 0;
}

posted @ 2017-02-27 12:03  wdan2016  阅读(626)  评论(1)    收藏  举报