hdu1402 A * B Problem Plus 高精度乘法 快速傅里叶变换(FFT)

Problem Description
Calculate A * B.
 

Input
Each line will contain two integers A and B. Process to end of file.

Note: the length of each integer will not exceed 50000.
 

Output
For each case, output A * B in one line.
 

Sample Input
 
   
1 2 1000 2
 

Sample Output
 
   
2 2000

模板题,具体请看代码注释

PS:wikioi3123需要把N改为400005,再去掉printf("\n");即可

#include 
#include 
#include 
#include 
#define N 200005
#define pi acos(-1.0) //PI值 
using namespace std;

struct complex
{
	double r,i;
	complex(double real=0.0,double image=0.0)
	{
		r=real;
		i=image;
	}
	//以下为三种虚数运算的定义 
	complex operator+(const complex o)
	{
		return complex(r+o.r,i+o.i);
	}
	complex operator-(const complex o)
	{
		return complex(r-o.r,i-o.i);
	}
	complex operator*(const complex o)
	{
		return complex(r*o.r-i*o.i,r*o.i+i*o.r);
	}
}x1[N],x2[N];
char a[N/2],b[N/2];
int sum[N]; //结果存在sum里 

void brc(complex *y,int l) //二进制平摊反转置换 O(logn) 
{
	register int i,j,k;
	for(i=1,j=l/2;i=k) //由最高位检索,遇1变0,遇0变1,跳出 
		{
			j-=k;
			k/=2;
		}
		if(j0)	l--; //检索最高位 
		for(i=l;i>=0;i--)
			putchar(sum[i]+'0'); //倒序输出 
		printf("\n");
	}
	return 0;
}

你可能感兴趣的:(HDU,WIKIOI,高精度模板,FFT)