首页 > 其他 > 详细

uva Teams

时间:2014-02-24 11:51:11      阅读:247      评论:0      收藏:0      [点我收藏+]

Problem E
Teams

Input: Standard Input

Output: Standard Output

 

In a galaxy far far away there is an ancient game played among the planets. The specialty of the game is that there is no limitation on the number of players in each team, as long as there is a captain in the team. (The game is totally strategic, so sometimes less player increases the chance to win). So the coaches who have a total of N players to play, selects K (1 ≤ K ≤ N) players and make one of them as the captain for each phase of the game. Your task is simple, just find in how many ways a coach can select a team from his N players. Remember that, teams with same players but having different captain are considered as different team.

 

Input

 

The first line of input contains the number of test cases T ≤ 500. Then each of the next T lines contains the value of N (1 ≤ N ≤ 10^9), the number of players the coach has.

 

Output

 

For each line of input output the case number, then the number of ways teams can be selected. You should output the result modulo 1000000007.

 

For exact formatting, see the sample input and output.

 

 

 

Sample Input                                                                               Output for Sample Input

3

1

2

3

Case #1: 1

Case #2: 4

Case #3: 12

 

 

 

 

Problem Setter: Towhidul Islam Talukdar

Special Thanks: Md. Arifuzzaman Arif

 

可选择的方式有n*2^n种;

代碼:

bubuko.com,布布扣
 1 #include <cstdio>
 2 #include <iostream>
 3 #include <algorithm>
 4 #include <cmath>
 5 typedef long long   LL;
 6 const long long nod = 1000000007;
 7 
 8 using namespace std;
 9 
10 LL PowerMod(int a,int b)  //快速幂取模算法
11 {
12     LL rec=(LL)1;
13     LL temp = (LL) a;
14     while(b)
15     {
16         if(b&1) rec=(rec*temp)%nod;
17         temp =(temp * temp)%nod;
18         b>>=1;
19     }
20     return rec%nod;
21 }
22 
23 int main()
24 {
25     int T,j;
26     int n;
27     while(~scanf("%d",&T))
28     {
29         for(j=1;j<=T;j++)
30         {
31             LL sum;
32             scanf("%d",&n);
33             //printf("CCC%d\n",PowerMod(2,n-1,1000000007));
34             sum=(n*PowerMod(2,n-1))%nod;
35             printf("Case #%d: %lld\n",j,sum);
36         }
37     }
38     return 0;
39 }
View Code

 

               

uva Teams

原文:http://www.cnblogs.com/gantaiyuan/p/3562167.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!