A classical probability problem (probability distribution problem)

Posted by clandestine555 on Mon, 20 Sep 2021 12:36:44 +0200

A classical probability problem

Time limit: 1 second for C / C + + and 2 seconds for other languages
Space limitation: C / C + + 26244k, other languages 524288K
64bit IO Format: %lld

Title Description  

Students bit noob and lit noob (hereinafter referred to as B and L) of Niuniu university took the course of "stochastic operations research" (a good course). As the name suggests, this course has a great relationship with randomness.

One day, the teacher gave an interesting programming problem: Please randomly generate 105105 strings in a unit circle (a circle with a radius of 11), program it, and output the length of these strings. This problem is not difficult. Both B and L will do it, but their practices are different.

The method of B is as follows: among all points in the circle, select a point P with equal probability to make the radius obtained by connecting the center O and P, make the vertical line of OP through point P, intersect the circle O at two points m and N, and the chord MN is the required value.

The method of L is: select a radius with equal probability among all the radii in the circle, and then select a point P with equal probability among all the points on this radius to make the radius obtained by connecting the center O and P, and make the vertical line of OP through point P to intersect the circle O at two points m and N, and the chord MN is the required value.

Finally, B and L each generated 105105 strings with their own methods, output the chord lengths of these strings, and submitted this operation.

But careless, they forgot to write their own name when naming their homework. In order to facilitate the teacher's scoring, they gave 105105 strings output by a program. Please help the teacher judge whose program this is.

Enter Description:

The first input line is an integer n(n=105)n(n=105), representing the number of chords to be input below.

The second line is nn real numbers, representing the chord length of a randomly generated string.

Ensure that the strings corresponding to nn real numbers in the input are either generated by the method of B or generated by the method of L.

Output Description:

Output a line of string. If the output comes from the program of B, output the character BB; If the output is from the program of L, the character LL is output.

Example 1

input

20
1.9821229 1.9248176 1.617335 0.10873477 1.9456689 1.402446 1.0166511 1.8566361 1.6386659 1.699187 1.5867242 1.3000285 1.96097 1.6946885 1.9999357 0.79870252 1.9004707 1.7499258 1.5236209 1.5751575

output

L

explain

 

The above input / output examples are only for the convenience of understanding the input / output format (of course, this group of data is indeed generated by the L method). In the actual test data, it is guaranteed that n=105n=105 is constant.

/*
*@Author:   GuoJinlong
*@Language: C++
*/
//#include <bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<string>
#include<queue>
#include<stack>
#include<map>
#include<vector>
#include<list>
#include<set>
#include<iomanip>
#include<cstring>
#include<cctype>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<cassert>
#include<sstream>
#include<algorithm>
using namespace std;
const int mod=1e9+7;
typedef long long  ll;
#define ls (p<<1)
#define rs (p<<1|1)
#define mid (l+r)/2
#define over(i,s,t) for(register long long i=s;i<=t;++i)
#define lver(i,t,s) for(register long long i=t;i>=s;--i)
const int MAXN = 305;
const int INF = 0x3f3f3f3f;
const int N=5e4+7;
const int maxn=1e5+5;
const double EPS=1e-10;
const double Pi=3.1415926535897;
//inline double max(double a,double b){
//    return a>b?a:b;
//}
//inline double min(double a,double b){
//    return a<b?a:b;
//}
 
int xd[8] = {0, 1, 0, -1, 1, 1, -1, -1};
int yd[8] = {1, 0, -1, 0, -1, 1, -1, 1};
 
//void Fire(){
//    queue<node> p;
//    p.push({fx,fy,0});
//    memset(fire, -1, sizeof(fire));
//    fire[fx][fy]=0;
//    while(!p.empty()){
//        node temp=p.front();
//        p.pop();
//        for(int i=0;i<8;i++){
//            int x=temp.x+xd[i];
//            int y=temp.y+yd[i];
//            if(x<0||x>=n||y<0||y>=m||fire[x][y]!=-1){
//                continue;
//            }
//            fire[x][y]=temp.val+1;
//            p.push({x,y,temp.val+1});
//        }
//    }
//}
//int bfs(){
//    queue<node> p;
//    memset(vis, 0, sizeof(vis));
//    p.push({sx,sy,0});
//    while (!p.empty()) {
//        node temp=p.front();
//        vis[temp.x][temp.y]=1;
//        p.pop();
//        for(int i=0;i<4;i++){
//            int x=temp.x+xd[i];
//            int y=temp.y+yd[i];
//            if(x<0||x>=n||y<0||y>=m)  continue;
//            if(x==ex&&y==ey&&temp.val+1<=fire[x][y]) return temp.val+1;
//            if(vis[x][y]||temp.val+1>=fire[x][y]||a[x][y]=='#') continue;
//            p.push({x,y,temp.val+1});
//        }
//    }
//    return -1;
//}

//One dimensional hash
//int n;
//string s;
//int bas=131;
//typedef unsigned long long ull;
//const ull mod1=100001651;
//ull a[100010];
//ull Hash(string s){
//    ll ans=0;
//    for(int i=0;i<s.size();i++){
//        ans*=bas;
//        ans+=int(s[i]);
//        ans%=mod1;
//    }
//    return ans;
//}

//Two dimensional hash
//using lom=unsigned long long ;
//const lom bas1=131,bas2=233;
//const int M=505;
//int n,m;
//char a[M][M];
//lom _hash[M][M];
//lom p1[M],p2[M];
//
//
//void init(){
//    p1[0]=1;
//    p2[0]=1;
//    for(int i=1;i<=505;i++){
//        p1[i]=p1[i-1]*bas1;
//        p2[i]=p2[i-1]*bas2;
//
//    }
//}
//void Hash(){
//    _hash[0][0]=_hash[0][1]=_hash[1][0]=0;
//    For (int i = 1; I < = n; I + +) {/ / prefix and
//        for(int j=1;j<=m;j++){
//            _hash[i][j]=_hash[i][j-1]*bas1+a[i][j]-'a';
//        }
//    }
//    For (int i = 1; I < = n; I + +) {/ / 2D prefix and
//        for(int j=1;j<=m;j++){
//            _hash[i][j]+=_hash[i-1][j]*bas2;
//        }
//    }
//
//}



int main(){
    
    int n;
    cin >> n;
    double a, sum = 0;
    for(int i = 1; i <= n; i++) {
        cin >> a;
        sum += a;
    }
    sum /= n;
    if(sum < 1.56) cout << "B";
    else cout << "L";
}

Topics: C++ iOS Algorithm codeforce AcWing