In a galaxy far awaythere is an alert ent game played among the planets. the specialty of the game isthat there is no limitation on the number of players in each team, as long asthere is a captain in the team. (The game is totally strategic, so sometimesless player increases the chance to win ). so the coaches who have a totalNPlayers to play, selectsK (1 ≤ k ≤ n)Players and makeone 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 hisNPlayers. Remember that, teams with same players but having different captain areconsidered as different team.
Input
Thefirst line of input contains the number of test casesT ≤ 500. Then each of the next t lines contains the valueN (1 ≤ n ≤ 10 ^ 9), The number of players the coach has.
Output
Foreach line of input output the case number, then the number of ways teams can beselected. You shoshould output the result modulo 1000000007.
Forexact formatting, see the sample input and output.
Sample input outputfor sample input
3 1 2 3 |
Case #1: 1 Case #2: 4 Case #3: 12 |
|
Problemsetter: towhidul Islam Talukdar
Specialthanks: Md. arifuzzaman Arif
Question: How many solutions are there for N people to select one or more people to participate in the competition, and one of them is the team leader? If the contestants are identical but the team leader is different, they are considered as different schemes.
Idea: it is easy to get sum = Σ I = 1nc [N] [I]? I, where C [N] [I] indicates the number of combinations. Then, based on the permutation formula, we get C [N] [I]? I = n? C [n? 1] [I? 1]
Then the result is sum = n? Σ I = 1nc [n? 1] [I? 1] = n? 2n? 1. Fast Power modulo
#include <iostream>#include <cstring>#include <cstdio>#include <algorithm>typedef long long ll;using namespace std;const ll mod = 1000000007;ll pow_mod(ll x, ll y) {ll ans = 1;while (y > 0) {if (y & 1)ans = ans * x % mod;y >>= 1;x = x * x % mod;}return ans;}ll n;int main() {int t, cas = 1;scanf("%d", &t);while (t--) {scanf("%lld", &n);printf("Case #%d: %lld\n", cas++, n*pow_mod(2ll, n-1) % mod);}return 0;}