游戏当中的秘密

因为我昨天玩游戏被骗,所以特此记录。(在飞机上算的,笑)

概率的游戏

假设现在有红、黄、蓝 \(3\) 种球各 \(8\) 个,让你摸出 \(12\) 个球(完全随机)。一共玩恰好 \(5\) 局游戏。假设有这个表:

你抽到的组合 你获得的钱数
543 -30
444 5
642 5
552 15
633 20
651 50
732 80
741 100
750 150
831 300
660 800
822 2000
840 5000

其中 \(abc\) 指的是按照抽的个数从大到小的个数。一共有 \(13\) 种组合。如果是你,你会玩吗?

如果算一下概率,即 \(abc\) 的概率是 \(\displaystyle \frac{\texttt{f}(a,b,c)\times \binom{8}{a}\times \binom{8}{b}\times \binom{8}{c}}{\binom{24}{12}}\),其中 \(\texttt{f}(a,b,c)\)\(1\) 如果 \(sz=|\{a,b,c\}|=1\)\(3\) 如果 \(sz=2\)\(6\) 如果 \(sz=3\)

那么,概率如下表:

你抽到的组合 你抽到这个组合的概率(\(\times 100\%\)
444 12.68418
543 48.70725
552 9.74145
633 9.74145
642 12.17681
651 2.78327
660 0.08698
732 2.78327
741 0.99403
750 0.09940
822 0.08698
831 0.09940
840 0.01553

如果计算 \(5\) 局你期望获得的钱数呢……是 \(-8.44042\)!是不是被骗了呢?

生成程序
#include <bits/stdc++.h>

using namespace std;

using ll = long long;

const int N = 60;

ll C[N][N];

void init(){
	C[0][0]=1;
	for (int i=1; i<N; i++){
		C[i][0]=1;
		for (int j=1; j<=i; j++){
			C[i][j]=C[i-1][j-1]+C[i-1][j];
		}
	}
}

ll cal(int a,int b,int c){
	set<int> st;
	st.insert(a),st.insert(b),st.insert(c);
	int sz=st.size();
	if (sz==1)return 1;
	if (sz==2)return 3;
	if (sz==3)return 6;
}

struct node {
	int a,b,c;
	long double pr;
	node (int _a,int _b,int _c,long double _p){
		a=_a,b=_b,c=_c,pr=_p;
	}
	bool operator < (const node &x) const {
		return pr>x.pr;
	}
};

const double mon[] = {-30,5,5,15,20,50,80,100,150,300,800,2000,5000};

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);

	init();
	ll al=C[24][12];
	long double sum=0;
	vector<node> v;
	for (int a=0; a<=8; a++){
		for (int b=0; b<=8; b++){
			for (int c=0; c<=8; c++){
				if (a+b+c==12 && a>=b && b>=c){		
					ll p=cal(a,b,c)*C[8][a]*C[8][b]*C[8][c];
					long double pr=1.*(long double)p/(1.*(long double)al);
					sum+=pr;
					v.push_back(node(a,b,c,pr));
				}
			}
		}
	}
	sort(v.begin(),v.end());
	int _=5;
	long double pr_mon=0;
	while (_--){
		int id=0;
		for (auto u : v){
			pr_mon+=u.pr*mon[id];
			id++;
		}
	}
	cout<<pr_mon<<endl;
	return 0;
}

无赖的游戏

这里是抽大奖环节!有一个格纸,每一个格子里面都有一个对应的奖品。有 \(4199\) 的 Iphone,也有 \(0.88\) 的红包。更重要的是,大奖(大于 \(3000\))和小奖(小于 \(5\))是交替的(一共偶数个格子,循环)。很傻的人会有一个念头,是不是 \(50\%\) 大奖

游戏规则如下:\(5\) 个骰子,设投出来的和为 \(x\)。那么你从第 \(x\) 格,跳 \(x\) 格就是你的奖品。

看出来了吧。\(2x≡0 \mod 2\)。所以,你只可能跳在偶数格子,即小奖上面!

那你会想,小奖也是有大小的,怎么分配大小呢?你算了一下概率。

你投出来的和 投这个和的概率(\(\times 100\%\)
5 0.01286
6 0.06430
7 0.19290
8 0.45010
9 0.90021
10 1.62037
11 2.63632
12 3.92233
13 5.40123
14 6.94444
15 8.37191
16 9.45216
17 10.03086
18 10.03086
19 9.45216
20 8.37191
21 6.94444
22 5.40123
23 3.92233
24 2.63632
25 1.62037
26 0.90021
27 0.45010
28 0.19290
29 0.06430
30 0.01286

看出来了,是中间高两边低的。像我就是抽到了 \(18\)

生成程序
#include <bits/stdc++.h>

using namespace std;

using ll = long long;

const int N = 33;

int cnt[N];

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);

	int sum=0;
	for (int a=1; a<=6; a++)
	for (int b=1; b<=6; b++)
	for (int c=1; c<=6; c++)
	for (int d=1; d<=6; d++)
	for (int e=1; e<=6; e++){
		sum++;
		cnt[a+b+c+d+e]++;
	}
	for (int i=5; i<=30; i++){
		long double pr=(long double)(1.*cnt[i])/(long double)(1.*sum);
		cout<<"| "<<i<<"  | "<<fixed<<setprecision(5)<<pr*100.<<"  |"<<endl;
	}
	return 0;
}

结语

大家玩游戏就图个乐子,不要抱什么希望!

posted @ 2024-02-06 21:45  SFlyer  阅读(50)  评论(0编辑  收藏  举报