poj 3734 Blocks (指数型母函数,泰勒级数展开)

http://poj.org/problem?id=3734

题意+思路同******hdu2065红色病毒解题报告

 1/* ***********************************************
 2Author :111qqz
 3Created Time :2016年02月27日 星期六 16时39分53秒
 4File Name :code/poj/3734.cpp
 5************************************************ */
 6
 7#include <cstdio>
 8#include <cstring>
 9#include <iostream>
10#include <algorithm>
11#include <vector>
12#include <queue>
13#include <set>
14#include <map>
15#include <string>
16#include <cmath>
17#include <cstdlib>
18#include <ctime>
19#define fst first
20#define sec second
21#define lson l,m,rt<<1
22#define rson m+1,r,rt<<1|1
23#define ms(a,x) memset(a,x,sizeof(a))
24typedef long long LL;
25#define pi pair < int ,int >
26#define MP make_pair
27
28using namespace std;
29const double eps = 1E-8;
30const int dx4[4]={1,0,0,-1};
31const int dy4[4]={0,-1,1,0};
32const int inf = 0x3f3f3f3f;
33const LL MOD =1E4+7;
34LL n;
35LL res;
36LL ksm(LL a,LL b)
37{
38    LL res = 1;
39    while (b)
40    {
41	if (b&1) res=(res*a)%MOD;
42	b = b>>1;
43	a = (a*a)%MOD;
44    }
45    return res;
46}
47int main()
48{
49	#ifndef  ONLINE_JUDGE 
50	freopen("code/in.txt","r",stdin);
51  #endif
52
53
54	int T;
55	cin>>T;
56	while (T--)
57	{
58	    scanf("%lld",&n);
59
60	    LL ans = ksm(4,n-1)+ksm(2,n-1);
61	    ans %=MOD;
62	    printf("%lld\n",ans);
63
64	}
65
66
67
68  #ifndef ONLINE_JUDGE  
69  fclose(stdin);
70  #endif
71    return 0;
72}