poj 3734 Fast exponential power generating function +

Referring to a combination of knowledge of the respective sections of mathematics, can be obtained:g^{(e)}(x) = (\sum_{n=0}^{\inf}\frac{x^{n}}{n!})^{2}(\sum_{m=0}^{\inf}\frac{x^{2m}}{2m!})^{2}

and so:f(n)=4^{n-1}+2^{n-1}

#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;
}

 

Published 22 original articles · won praise 0 · Views 7397

Guess you like

Origin blog.csdn.net/georgeandgeorge/article/details/97159466