Teams UVA - 11609(快速幂板题)

时间:2023-03-09 05:06:44
Teams UVA - 11609(快速幂板题)

写的话就是排列组合。。。但能化简。。。ΣC(n,i)*C(i,1) 化简为n*2^(n-1) ;

#include <iostream>
#include <cstdio>
#include <sstream>
#include <cstring>
#include <map>
#include <set>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
#include <cmath>
#define MOD 1000000007
#define LL long long
#define ULL unsigned long long
#define Pair pair<int, int>
#define mem(a, b) memset(a, b, sizeof(a))
#define _ ios_base::sync_with_stdio(0),cin.tie(0)
//freopen("1.txt", "r", stdin);
using namespace std;
const int maxn = , INF = 0x7fffffff;
LL down[maxn], up[maxn]; LL qpow(LL a, LL b)
{
LL res = ;
while(b)
{
if(b & ) res = res * a % MOD;
a = a * a % MOD;
b >>= ;
}
return res;
}
//
//void init()
//{
// up[0] = 1;
// down[0] = 1;
// for(int i=1; i<maxn; i++)
// {
// up[i] = up[i-1] * i % MOD;
// down[i] = qpow(up[i], MOD - 2);
// }
//}
//
//LL C(LL n, LL m)
//{
// return up[n] * down[m] % MOD * down[n-m] % MOD;
//} int main()
{
int T, kase = ;
// init();
cin>> T;
while(T--)
{
LL n, res = , m;
cin>> n; printf("Case #%d: %lld\n",++kase, n * qpow(, n-) % MOD); // cout<< C(n, m) <<endl; } return ;
}