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

include "stdafx.h"

#include<iostream>
#include<vector>

#include<math.h>
#include <iomanip>
using namespace std;

int main()
{
    int n,m, x, y, t;
    while (cin>>n>>m>>x>>y>>t)
    {
        vector<vector<float>> pVec;
        for (int i = 0; i < n; i++)
        {
            vector<float>  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;
}

转载于:https://www.cnblogs.com/wdan2016/p/6473152.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值