poj 3734 Blocks (指数型母函数,泰勒级数展开)
http://poj.org/problem?id=3734
题意+思路同******hdu2065红色病毒解题报告
/* ***********************************************
Author :111qqz
Created Time :2016年02月27日 星期六 16时39分53秒
File Name :code/poj/3734.cpp
************************************************ */
1#include <cstdio>
2#include <cstring>
3#include <iostream>
4#include <algorithm>
5#include <vector>
6#include <queue>
7#include <set>
8#include <map>
9#include <string>
10#include <cmath>
11#include <cstdlib>
12#include <ctime>
13#define fst first
14#define sec second
15#define lson l,m,rt<<1
16#define rson m+1,r,rt<<1|1
17#define ms(a,x) memset(a,x,sizeof(a))
18typedef long long LL;
19#define pi pair < int ,int >
20#define MP make_pair
1using namespace std;
2const double eps = 1E-8;
3const int dx4[4]={1,0,0,-1};
4const int dy4[4]={0,-1,1,0};
5const int inf = 0x3f3f3f3f;
6const LL MOD =1E4+7;
7LL n;
8LL res;
9LL ksm(LL a,LL b)
10{
11 LL res = 1;
12 while (b)
13 {
14 if (b&1) res=(res*a)%MOD;
15 b = b>>1;
16 a = (a*a)%MOD;
17 }
18 return res;
19}
20int main()
21{
22 #ifndef ONLINE_JUDGE
23 freopen("code/in.txt","r",stdin);
24 #endif
1 int T;
2 cin>>T;
3 while (T--)
4 {
5 scanf("%lld",&n);
1 LL ans = ksm(4,n-1)+ksm(2,n-1);
2 ans %=MOD;
3 printf("%lld\n",ans);
}
1 #ifndef ONLINE_JUDGE
2 fclose(stdin);
3 #endif
4 return 0;
5}