https://vjudge.net/problem/UVA-11609

题意:

有n个人,选一个或多个人参加比赛,其中一名当队长,有多少种方案?如果参赛者完全相同,但队长不同,算作不同的方案。

思路:

之后就是快速幂处理。

 #include<iostream>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<vector>
#include<queue>
#include<cmath>
using namespace std; typedef long long LL; const int MOD=; LL n; LL pow(LL n)
{
LL res=,base=;
while(n)
{
if(n&)
res=(res*base)%MOD;
base=(base*base)%MOD;
n>>=;
}
return res;
} int main()
{
//freopen("D:\\input.txt","r",stdin);
int T;
scanf("%d",&T);
for(int kase=;kase<=T;kase++)
{
scanf("%lld",&n);
LL ans = pow(n-);
printf("Case #%d: %lld\n",kase,(n*ans)%MOD);
}
}

UVa 11609 组队(快速幂)的更多相关文章

  1. Teams UVA - 11609(快速幂板题)

    写的话就是排列组合...但能化简...ΣC(n,i)*C(i,1) 化简为n*2^(n-1) ; #include <iostream> #include <cstdio> # ...

  2. UVA - 11149 (矩阵快速幂+倍增法)

    第一道矩阵快速幂的题:模板题: #include<stack> #include<queue> #include<cmath> #include<cstdio ...

  3. Colossal Fibonacci Numbers! UVA - 11582(快速幂,求解)

    Problem Description The i’th Fibonacci number f(i) is recursively defined in the following way: •f(0 ...

  4. UVa 10870 & 矩阵快速幂

    题意: 求一个递推式(不好怎么概括..)的函数的值. 即 f(n)=a1f(n-1)+a2f(n-2)+...+adf(n-d); SOL: 根据矩阵乘法的定义我们可以很容易地构造出矩阵,每次乘法即可 ...

  5. UVa 10870 (矩阵快速幂) Recurrences

    给出一个d阶线性递推关系,求f(n) mod m的值. , 求出An-dv0,该向量的最后一个元素就是所求. #include <iostream> #include <cstdio ...

  6. Carmichael Numbers (Uva No.10006) -- 快速幂运算_埃氏筛法_打表

    #include <cstdio> #include <iostream> #include <algorithm> #include <cmath> ...

  7. UVA 11609 Teams 组合数学+快速幂

    In a galaxy far far away there is an ancient game played among the planets. The specialty of the gam ...

  8. UVA 11609 - Teams 组合、快速幂取模

    看题传送门 题目大意: 有n个人,选一个或者多个人参加比赛,其中一名当队长,如果参赛者相同,队长不同,也算一种方案.求一共有多少种方案. 思路: 排列组合问题. 先选队长有C(n , 1)种 然后从n ...

  9. POJ-3070Fibonacci(矩阵快速幂求Fibonacci数列) uva 10689 Yet another Number Sequence【矩阵快速幂】

    典型的两道矩阵快速幂求斐波那契数列 POJ 那是 默认a=0,b=1 UVA 一般情况是 斐波那契f(n)=(n-1)次幂情况下的(ans.m[0][0] * b + ans.m[0][1] * a) ...

随机推荐

  1. ios UIImage图片拉伸 resizableImageWithCapInsets:

    常见的按钮添加和背景设置如下: UIButton *button = [[UIButton alloc] initWithFrame:CGRectMake(80, 130, 160, 44)];[bu ...

  2. tomcat项目快速启动设置

    1.现象:tomcat启动项目时,耗费10几秒的时间 2.(tomcat7)解决:打开$JAVA_HOME/jre/lib/security/java.security这个文件 找到下面的内容:sec ...

  3. thinkphp---自动验证的问题

    这段时间做一个项目:使用 thinkphp 做了一个自动验证,但是发现如果新增的时候,是能够进行自动验证的,但是在修改的修改的时候,会发现自动验证会失效. 验证的时候,模型是这样写的: protect ...

  4. 转!idea 破解版 安装

    原博文地址:https://blog.csdn.net/everest_man/article/details/78985879 1.官网下载  Ultimate版本 2.http://idea.la ...

  5. android 导出数据库文件

    1.打开dos窗口,进入自己SDK路径下,再进入platform-tools下边 2.进入shell模式: adb shell 3.获取所有root权限: su root 4.打开需要导出的数据库文件 ...

  6. uchome 全局变量

    $_SC: Array ( [dbhost] => localhost [dbuser] => root [dbpw] => root [dbcharset] => utf8 ...

  7. UChome Feed 机制

    Feed,本意是“饲料.饲养.(新闻的)广播等”. 我们就拿用户发表日志这个动作来简单看看Uchome的feed机制. 用户发布日志所使用的函数是 source/function_blog.php文件 ...

  8. 如何在python3.5环境下安装BeautifulSoup?

    首先是安装: 1.到http://www.crummy.com/software/BeautifulSoup/网站上上下载 2.下载完成之后需要解压缩,假设放到D:/python下. 3.运行cmd, ...

  9. Linux下编译安装PHP扩展memcached

    [安装 libevent] $ tar zxvf libevent-2.0.20-stable.tar.gz $ cd libevent-2.0.20-stable/$ ./configure --p ...

  10. 基于struts2框架-自定义身份证号验证器

    自定义拦截器的步骤: 1.定义一个验证器的类: > 自定义的验证器都需要实现 Validator接口.  > 可以选择继承 ValidatorSupport 或 FieldValidato ...