题意:房间内有
数据范围与约定:
解析:一道很仙的题,有个巧妙的思路。
我们不考虑进入房间走的哪扇门,因为它只与行走的方向有关。所以题目等价于每个人从其目标位置开始按照既定方向走动即可。
我们可以想象每个人都在一个
那么每个人的目标位置有
/*
* @Author: clorf
* @Date: 2021-02-16 22:19:51
* @Last Modified by: clorf
* @Last Modified time: 2021-02-16 22:34:35
*/
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<algorithm>
#include<ctime>
#include<cctype>
#define INF 2e9
#define rg register
using namespace std;
const int mod=1e9+7;
const int maxn=1000000;
const long double Pi=acos(-1.0);
const double eps=1e-7;
//1.数组开小
//2.没用long long/爆了类型存储范围
//3.写之前式子没推清楚
//4.变量写错(想当然typo/没想清楚含义)
//5.写之前没想清楚复杂度
//6.常量数字与long long连用时要加ll!!!
//7.考虑无解和多解的情况
//8.两个int连成爆long long的一定要加1ll!!!!
//9.先除后乘!!!!!!
template<class T>void read(T &x)
{
x=0;int f=0;char ch=getchar();
while(!isdigit(ch)){f|=(ch=='-');ch=getchar();}
while(isdigit(ch)){x=(x<<1)+(x<<3)+(ch^48);ch=getchar();}
x=f?-x:x;
return;
}
int n,m,ans;
inline int power(int a,int b,int p)
{
int ans=1;
for(;b;b>>=1)
{
if(b&1)
ans=1ll*ans*a%p;
a=1ll*a*a%p;
}
return ans;
}
inline int inv(int x)
{
return power(x,mod-2,mod);
}
int main()
{
scanf("%d%d",&n,&m);
printf("%d",1ll*(n+1+mod-m)%mod*inv(n+1)%mod*power((n+1)<<1,m,mod)%mod);
return 0;
}

