UVa 11609 组队(快速幂)

时间:2023-03-10 06:37:34
UVa 11609 组队(快速幂)

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

题意:

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

思路:

UVa 11609 组队(快速幂)

之后就是快速幂处理。

 #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);
}
}