【BZOJ5300】[CQOI2018]九连环 (高精度,FFT)

【BZOJ5300】[CQOI2018]九连环 (高精度,FFT)

题面

BZOJ
洛谷

题解

去这里看吧,多么好

#include
#include
#include
#include
using namespace std;
#define MAX 150000
const double Pi=acos(-1);
inline int read()
{
    int x=0;bool t=false;char ch=getchar();
    while((ch<'0'||ch>'9')&&ch!='-')ch=getchar();
    if(ch=='-')t=true,ch=getchar();
    while(ch<='9'&&ch>='0')x=x*10+ch-48,ch=getchar();
    return t?-x:x;
}
struct Complex{double a,b;}A[MAX],B[MAX],W[MAX];
Complex operator+(Complex a,Complex b){return (Complex){a.a+b.a,a.b+b.b};}
Complex operator-(Complex a,Complex b){return (Complex){a.a-b.a,a.b-b.b};}
Complex operator*(Complex a,Complex b){return (Complex){a.a*b.a-a.b*b.b,a.b*b.a+a.a*b.b};}
int r[MAX],N,l=0;
void FFT(Complex *P,int N,int opt)
{
    for(int i=0;i>1]>>1)|((i&1)<<(l-1));
    for(int i=1;i>=1;
        }
        bool o=false;int s=0;
        for(int i=la;~i;--i)
        {
            s=s*10+a[i];
            if(s<3&&!o)continue;
            o=true;printf("%d",s/3);s%=3;
        }
        puts("");
    }
}

转载于:https://www.cnblogs.com/cjyyb/p/10403464.html

你可能感兴趣的:(【BZOJ5300】[CQOI2018]九连环 (高精度,FFT))