1. 程式人生 > >Teams UVA - 11609(快速冪板題)

Teams UVA - 11609(快速冪板題)

stdin 排列 map ace for () ffffff pri str

寫的話就是排列組合。。。但能化簡。。。Σ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 = 1000000, INF = 0x7fffffff; LL down[maxn], up[maxn]; LL qpow(LL a, LL b) { LL res
= 1; while(b) { if(b & 1) res = res * a % MOD; a = a * a % MOD; b >>= 1; } 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 = 0; // init(); cin>> T; while(T--) { LL n, res = 0, m; cin>> n; printf("Case #%d: %lld\n",++kase, n * qpow(2, n-1) % MOD); // cout<< C(n, m) <<endl; } return 0; }

Teams UVA - 11609(快速冪板題)