UVa 11609 Teams (combinatorial mathematics)

Source: Internet
Author: User
Tags pow time limit

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/

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.