题目大意:
有n个互不相同的整数,分成A,B两组满足下面的关系
A队中能力最大的Agent的能力值要小于BB队能力最弱的Agent的能力值。
A,BA,B两队都要有人参战。
思路:
我们考虑枚举一个i一定是A队的,那么左边可以任意选就是2(i-1),右边除了全空都可以选2(n-i)-1,然后相乘为2n-1-2i-1,后面的是个等比数列,直接等比数列求和就好了,前面的是一个常数列随便搞搞。
程序:
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstdlib>
#define LL long long
using namespace std;
const int mo=1e9+7;
const int N=10005;
LL ans,n;
LL ksm(LL x,int y){
if (y==1) return x;
if (y==0) return 1;
LL o=ksm(x,y/2);
o=(o*o)%mo;
if (y%2==1) o=(o*x)%mo;
return o;
}
int main(){
scanf("%lld",&n);
ans=((n-2)*ksm(2,n-1)+1)%mo;
printf("%lld",ans);
}