HDU_4609_3-idiots

题型:数论


题意:n条线段,取3个组成三角形的概率


分析:

gg bin对于这题的blog写的最棒了~

http://www.cnblogs.com/kuangbin/archive/2013/07/24/3210565.html

我just贴代码。


代码:

#include
#include
#include
#include
#include

#define LL long long
#define mt(a,b) memset(a,b,sizeof(a))

using namespace std;

const int M = 1e5+100;

struct Complex {///复数结构体
    double x,y;///实部和虚部 x+yi
    Complex(double _x=0,double _y=0) {
        x=_x;
        y=_y;
    }
    friend Complex operator -(const Complex &a,const Complex &b) {
        return Complex(a.x-b.x,a.y-b.y);
    }
    friend Complex operator +(const Complex &a,const Complex &b) {
        return Complex(a.x+b.x,a.y+b.y);
    }
    friend Complex operator *(const Complex &a,const Complex &b) {
        return Complex(a.x*b.x-a.y*b.y,a.x*b.y+a.y*b.x);
    }
};
class FFT {///快速傅里叶变换
    Complex u,t;
    void change(Complex y[],int len) { ///len必须是2的幂
        for(int i=1,j=len>>1,k; i>1;
            while(j>=k) {
                j-=k;
                k>>=1;
            }
            if(j>1;
                for(int k=j; k



你可能感兴趣的:(ACM,HDU,acm,数论)