Uva 11609 - Teams 解题报告(组合数学)
来源:互联网 发布:00后宝妈直播软件 编辑:程序博客网 时间:2024/06/10 00:33
Problem E
Teams
Input: Standard Input
Output: Standard Output
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 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 how many ways a coach can select a team from hisN players. Remember that, teams with same players but having different captain are considered as different team.
Input
The first line of input contains the number of test cases T ≤ 500. Then each of the next T lines contains the value ofN (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 be selected. You should output the result modulo 1000000007.
For exact formatting, see the sample input and output.
Sample Input Output for Sample Input
3
1
2
3
Case #1: 1
Case #2: 4
Case #3: 12
Problem Setter: Towhidul Islam Talukdar
Special Thanks: Md. Arifuzzaman Arif
解题报告:大水题。先从n个人中选出冠军,一共n种选法。其他人在或者不在,都是两种情况,一共2^(n-1)种情况。二分快速幂一下。代码如下:
#include <cstdio>#include <cstring>#include <algorithm>using namespace std;const int mod = 1000000007;typedef long long LL;LL powMod(LL a, LL b){ LL res=1; while(b) { if(b&1) res = res*a%mod; a=a*a%mod; b>>=1; } return res;}int cas=1;void work(){ int n; scanf("%d",&n); printf("Case #%d: %lld\n", cas++, powMod(2, n-1)*n%mod);}int main(){ int T; scanf("%d",&T); while(T--) work();}
- Uva 11609 - Teams 解题报告(组合数学)
- UVa 11609 - Teams (组合数学)
- UVa 11609 Teams (组合数学)
- UVa 11609 Teams (组合数学)
- uva 11609 - Teams(组合数学+快速幂)
- Uva 11076 Add Again 解题报告(组合数学)
- UVa-11609 Teams(组合+快速幂)
- UVA-11609-Teams-组合计数
- Uva 1319 - Maximum 解题报告(数学)
- Uva 1388 Graveyard 解题报告(数学)
- UVa 11609 - Teams(组合数+快速幂)
- Teams(UVA 11609)
- UVA 11609 - Teams 组合、快速幂取模
- UVa 11609 Teams(快速幂+数学)
- POJ 1496 Word Index组合数学(解题报告)
- POJ 1850 Code组合数学(解题报告)
- BZOJ3997: [TJOI2015]组合数学 解题报告
- BZOJ 1008 组合数学 解题报告
- 在面试MySQL DBA或者那些打算做MySQL性能优化的人时
- OutputStreamWriter
- [PHP]CakePHP学习(一)
- DMA中burst的概念
- git学习五(分支的衍合rebase)
- Uva 11609 - Teams 解题报告(组合数学)
- MFC使用SendMessage()发送自定义消息实现进程间通信
- 在线帮助(类似客服) jquery实现(待优化)
- Eclipse Java注释模板设置详解
- 利用ffmpeg和SDL实现一个跨android版本的音视频播放器
- 日志
- 中小规模软件设计及管理方法 - 程序员 1
- 在线文档
- ActionBar的向上导航和返回键