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 inthe team. (The game is totally strategic, so sometimes less player increases the chance to win). So thecoaches who have a total of N players to play, selects K (1 ≤ K ≤ N) players and make one of themas the captain for each phase of the game. Your task is simple, just find in how many ways a coachcan select a team from his N players. Remember that, teams with same players but having differentcaptain are considered as different team.InputThe first line of input contains the number of test cases T ≤ 500. Then each of the next T lines containsthe value of N (1 ≤ N ≤ 109), the number of players the coach has.OutputFor each line of input output the case number, then the number of ways teams can be selected. Youshould output the result modulo 1000000007.For exact formatting, see the sample input and output.Sample Input3123Sample OutputCase #1: 1Case #2: 4Case #3: 12题意:给你一个n,n个人,标号为1~n,现在选若干人组成一队,并且选出一个队长,问说可以选多少种队伍,队长,人数,成员不同均算不同的队伍。
题解:我们枚举选择k个人(1<=k<=n)
答案就是: 1*c(n,1)+2*c(n,2)+.......+n*c(n,n);
接着提出n
化为: n*(c(n-1,0)+c(n-1,1)+c(n-1,2)+......+c(n-1,n-1));
答案就是:n*(2^(n-1));快速幂求解
//meek///#include#include #include #include #include #include #include #include #include