11609-teams
Time limit:1.000 seconds
Http://uva.onlinejudge.org/index.php? OPTION=COM_ONLINEJUDGE&ITEMID=8&CATEGORY=467&PAGE=SHOW_PROBLEM&PROBLEM=26 56
In a galaxy far far away there be an ancient game played among the planets. The specialty of the game is this there is no limitation on the number of players in each team, as long as there be a capt Ain 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 the many ways a coach can select a team from his N players. Remember that, teams with same players but has different captain, are considered as different team.
Input
The "a" 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 is selected. You are should output the result modulo 1000000007.
For exact formatting, the sample input and output.
Sample input Output for sample input
3 1 2 3 |
Case #1:1 Case #2:4 Case #3:12 |
Idea: Easy to get results for
Complete code:
/*0.012s*/
#include <cstdio>
#define LL long-long
const int mod = 1000000007;
ll Pow (ll A, ll b)///a^b% mod
{
ll R = 1, base = A;
while (b)
{
if (b & 1)
R = R * Base% MoD;
Base = base * Base% MoD;
b >>= 1;
}
return r;
}
int main (void)
{
int T, case = 0;
ll N;
scanf ("%d", &t);
while (t--)
{
scanf ("%lld", &n);
printf ("Case #%d:%lld\n", ++case, (n * POW (2, n-1))% mod);
}
See more highlights of this column: http://www.bianceng.cnhttp://www.bianceng.cn/Programming/sjjg/