Referring to a combination of knowledge of the respective sections of mathematics, can be obtained:
and so:
#include <iostream>
#include <vector>
#include <string.h>
#include<stdlib.h>
#include<cstdio>
#include<string>
#include<string.h>
#include<math.h>
#include<map>
#include<algorithm>
#include<functional>
#define MOD 10007
using namespace std;
long long binpow(long long a, long long b)
{
a %= MOD;
long long res = 1;
while (b > 0)
{
if (b & 1)
res = res * a%MOD;
a = a * a%MOD;
b >>= 1;
}
return res;
}
int main()
{
int T,N;
scanf("%d",&T);
{
for (int i = 0; i < T; ++i)
{
scanf("%d",&N);
long long res_2 = binpow(2,N-1);
res_2 += res_2*res_2%MOD;
printf("%lld\n",res_2%MOD);
}
}
return 0;
}