19-11-10-∴

一年$\mathsf{OI}$一场空,三道林先森见祖宗。

心态场:ZJ:

27
Miemeng 20
00:00:41
30
00:00:41
0
00:00:42
50
00:00:42

传说$T1$我打的是题目意思的“正解”???

不管了,反正是手玩性质直接干的。

能骗$20$分谢天谢地了。

$T2$暴力写死了,本来可以有$65$的。

因为题目太思维所以很心态。

TJ:

关于题解,我只写个$T1$吧。

T1‘

首先解释一下题意,现在有一张表,

然后$ans$值在下标为$i$的位置,

但是在取$i$的时候两个人在位上按概率$50\%$行动,于是会有偏移,

现在要求差的期望。

柿子:

$$ans= {\sum \limits_{i=0}^{2^k-1}|a_{i}-a_{anspos}| \over 2^{k}} $$

#include <iostream>
#include <cstring>
#include <cstdio>
#include <cmath>
#define N (1<<18)+111
#define LL long long

using namespace std;

// understood...but emm...

const int Mod=1e9+7;
int k,anspos;
int arr[N];
LL ans=0;
LL ppow(LL a,LL b){
	LL res=1;
	while(b){
		if(b&1)res=res*a%Mod;
		a=a*a%Mod;
		b>>=1;
	}
	return res;
}
int main(){
#ifndef LOCAL
	freopen("table.in" ,"r",stdin);
	freopen("table.out","w",stdout);
#endif
	scanf("%d%d",&k,&anspos);
	for(int i=0;i<1<<k;i++)
		scanf("%d",arr+i);
	for(int i=0;i<1<<k;i++){
		ans+=abs(arr[anspos]-arr[i]);
		ans%=Mod;
	}
	ans=ans*ppow(ppow(2,k),Mod-2)%Mod;
	cout<<ans<<endl;
}

 

posted @ 2019-11-10 11:54  Miemeng_麦蒙  阅读(219)  评论(0编辑  收藏  举报

小麦在雨中,蒙蒙的雾气

麦蒙不想有人骚扰他,如果有必要 联系 QQ:1755601414

如果你嫌广告大,那就喷我吧,不是博客园的锅。