1. 程式人生 > >UVA 11609 Teams (組合水題)

UVA 11609 Teams (組合水題)

#include<bits/stdc++.h>
using namespace std;
#define debug puts("YES");
#define rep(x,y,z) for(int (x)=(y);(x)<(z);(x)++)
#define read(x,y) scanf("%d%d",&x,&y)
#define ll long long
#define lrt int l,int r,int rt
#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
const int  maxn =5e4+5;
const int mod=1e9+7;
ll powmod(ll x,ll y){ll t=1;for(;y;x=x*x%mod,y>>=1) if(y&1) t=t*x%mod;return t;}
ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
/*
組合水題,讀懂題意就可以了,
就是n個人中任選k個人,且要令一個人為隊長,
隊長不同成員完全一樣也算不同,問有多少種選擇方法。
推公式或者直接組合思想都可以。
*/
int main()
{
    int t;scanf("%d",&t);
    for(int ca=1;ca<=t;ca++)
    {
        ll n;scanf("%lld",&n);
        printf("Case #%d: %lld\n",ca,n*powmod(2LL,n-1)%mod);
    }
    return 0;
}