Teams(uva11609+组合)

2015-11-21 00:59:38 · 作者: · 浏览: 4

I - Teams Time Limit:1000MS Memory Limit:0KB 64bit IO Format:%lld & %llu

Submit Status Practice UVA 11609

\

?

题意:有n个人,选多个人参加比赛,其中一个是队长,队长不同其他选手相同也算作不同的方案,。问你一共有多少种方案。

思路:自己才纸上稍微推理一下,n*2n-1%mod;

转载请注明出处:寻找&星空の孩子

题目链接:UVA 11609

?

也欢迎来我开的专题刷题。哈哈http://acm.hust.edu.cn/vjudge/contest/view.action?cid=77956#overview

?

?

#include
  
   
#define mod 1000000007
#define LL long long
LL ppow(LL x,LL n)
{
    LL tp=1;
    while(n)
    {
        if(n&1) tp=tp*x%mod;
        n>>=1;
        x=x*x%mod;
    }
    return tp;
}
int main()
{
    int ca=1,T;
    scanf("%d",&T);
    LL n;
    while(ca<=T)
    {
        scanf("%lld",&n);
        printf("Case #%d: %lld\n",ca++,(n*ppow(2,n-1))%mod);
    }
    return 0;
}
  

?

?