跳到正文

剪贴板

剪贴板 8xgns0n2

原文
剪贴板信息

剪贴板信息

收录
更新
C++
struct Cp{
	double a,b;
	Cp(double aa=0,double bb=0):a(aa),b(bb){}
	Cp operator+(Cp x)const{return Cp(a+x.a,b+x.b);}
	Cp operator-(Cp x)const{return Cp(a-x.a,b-x.b);}
	Cp operator*(Cp x)const{return Cp(a*x.a-b*x.b,a*x.b+b*x.a);}
	Cp operator~()const{return Cp(a,-b);}
};
double abs(Cp a){return sqrt(a.a*a.a+a.b*a.b);}
C++
const int p=1e9+7;
template<class _Tp,class _tp>void add(_Tp&x,const _tp& y){((x+=y)>=p)&&(x-=p);}template<class _Tp,class _tp>_Tp Add(_Tp x,const _tp y){add(x,y);return x;}
template<class _Tp,class _tp>void sub(_Tp&x,const _tp&y){((x-=y)<0)&&(x+=p);}template<class _Tp,class _tp>_Tp Sub(_Tp x,const _tp y){sub(x,y);return x;}
template<class _Tp,class _tp>void mul(_Tp&x,const _tp&y){x=1ll*x*y%p;}template<class _Tp,class _tp>_Tp Mul(const _Tp x,const _tp y){return 1ll*x*y%p;}
template<class _Tp,class _tp>_Tp ksm(_Tp a,_tp b){_Tp ans(1);for(;b;b>>=1,mul(a,a))if(b&1)mul(ans,a);return ans;}
template<class _Tp>_Tp div2(_Tp a){if(a&1)a+=p;return a>>1;}
struct Cp{
	int a,b;
	Cp(int A=0,int B=0):a(A),b(B){}
	inline Cp operator+(Cp x)const{return Cp(Add(a,x.a),Add(b,x.b));}
	inline Cp operator-(Cp x)const{return Cp(Sub(a,x.a),Sub(b,x.b));}
	inline Cp operator*(Cp x)const{return Cp(Add(Mul(a,x.a),Mul(5,Mul(b,x.b))),Add(Mul(a,x.b),Mul(b,x.a)));}
	inline Cp operator~()const{return Cp(a,p-b);}
};