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. BFS+状态压缩DP+二分枚举+TSP

    http://acm.hdu.edu.cn/showproblem.php?pid=3681 Prison Break Time Limit: 5000/2000 MS (Java/Others)   ...

  2. rest_framework之规范详解 00

    接口开发 方式1:缺点:如果有10张表,则需要40个url. urls.py views.py 缺点:如果有10张表,则需要40个url.    接下来就出现了resrful 规范,比较简洁 方式2: ...

  3. php程序中判断session过期

    我们最常用的是在php程序中设置,如下例程序所示: if(!isset($_SESSION['abc']) || time()-$_SESSION['abc']>60){ $_SESSION[' ...

  4. Maven搭建Nexus私有仓库

    下载压缩包nexus-2.13.0-01-bundle.tar.gz 解压后有两个目录 进入程序目录启动 ./nexus start 启动告警(确认用root启动把以下加入到环境变量) export ...

  5. kibana 和ES安装配置常见问题解决

    1.下载相同版本的kibana和ES: es5.6.5下载地址:https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-5 ...

  6. html/css实现文字自动换行,超出部分出现(...)

    PS:这是我在别人博客copy下来的 做前端的我们都会发现这样一个问题,当你控制文字出现多行时,而这多行是有限制的(比如超出部分隐藏不显示),而这多行文字如果全部是数字或者字母抑或是数字和字母的组合时 ...

  7. django haystack

    # coding=utf-8 from haystack import indexes from yw_asset.models import * class AssetIndex(indexes.S ...

  8. 商铺项目(Redis缓存)

    AOF,RDB是两种 redis持久化的机制.用于crash后,redis的恢复. 两种区别就是,AOF是持续的用日志记录写操作,crash后利用日志恢复:RDB是平时写操作的时候不触发写,只有手动提 ...

  9. android 百度地图 No implementation found for int

    java.lang.UnsatisfiedLinkError: No implementation found for int com.baidu.platform.comjni.map.common ...

  10. 为什么Log.nsf中存储的日志只有最近7天的原因

    是由于Domino服务器的notes.ini配置文件中有一行参数: Log = logfilename, log_option, not_used, days, size 比如:Log=log.nsf ...