UVa 11609

From Algorithmist
Jump to navigation Jump to search

Problem Number - Problem Name[edit]

  • UVa 11609: Teams [1]

Summary[edit]

How many ways a coach can select a team from his N players.

Explanation[edit]

Just calculate pow(2,n-1)*n

Notes[edit]

  • If you use pow function you will get TLE. You have to implement pow function in O(logn)

Implementations[edit]

int power(int x, int y) {

   int temp;
   if( y == 0)
       return 1;
   temp = power(x, y/2);
   if (y%2 == 0)
       return temp*temp;
   else
       return x*temp*temp;

}

Input[edit]

4
1
2
3
1000000000

Output[edit]

Case #1: 1
Case #2: 4
Case #3: 12
Case #4: 7812500