一个经典概率问题(概率分布问题)

一个经典概率问题

时间限制:C/C++ 1秒,其他语言2秒
空间限制:C/C++ 262144K,其他语言524288K
64bit IO Format: %lld

题目描述 

牛牛大学的学生bit-noob与lit-noob(以下简称B和L)选修了"随机运筹学"这门课程(是门好课),顾名思义,这门课和随机有着很大的关系。

一天,老师出了一道有趣的编程题:请在一个单位圆(半径为11的圆)中随机生成105105条弦,编程实现,并输出这些弦的长度。这个问题并不困难,B和L都会做,但他们的做法不尽相同。

B的做法为:在圆内所有的点中,等概率的选择一个点P,做连接圆心O与P得到的半径,过P点做OP的垂线交圆O于M,N两点,弦MN即为所求。

L的做法为:在圆内所有的半径中,等概率的选择一条半径,再在这条半径上的所有点中,等概率的选择一个点P,做连接圆心O与P得到的半径,过P点做OP的垂线交圆O于M,N两点,弦MN即为所求。

最终,B和L各自用自己的方法生成了105105条弦,并输出了这些弦的弦长,提交了这次作业。

但粗心的他们忘记在给作业命名的时候写上自己的名字了,为了方便老师登分,给出某个程序输出的105105条弦,请帮助老师判断这是谁的程序。

输入描述:

输入第一行是一个整数n(n=105)n(n=105),表示下面将输入的弦数。

第二行是nn个实数,表示随机生成的一条弦的弦长。

保证输入当中的nn个实数所对应的弦要么全是使用B的方法生成的,要么全是使用L的方法生成的。

输出描述:

输出一行字符串,若该输出来自B的程序,输出字符BB;若该输出来自L的程序,输出字符LL。

示例1

输入

复制

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

输出

复制

L

说明

 

上述输入输出示例只是为了便于理解输入输出的格式(当然,该组数据确实是用L的方法生成的),实际的测试数据中,保证n=105n=105恒成立。

/*
*@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;
//}

//一维哈希
//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;
//}

//二维哈希
//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++){    //前缀和
//        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++){   //二维前缀和
//        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";
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

郭晋龙

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值