• 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;
    }
  • 相关阅读:
    0421 & SX2016
    HDU3948 & 回文树模板
    BZOJ 2152 & 点分治
    HDU5618 & CDQ分治
    CC countari & 分块+FFT
    ECF R9(632E) & FFT
    ECF R9(632E) & DP
    BZOJ的两道osu概率DP easy与osu
    BZOJ3197 & 组合乱搞
    转载 Rational Rose 的配置和破解
  • 原文地址:https://www.cnblogs.com/wdan2016/p/6473152.html
Copyright © 2020-2023  润新知