FTT/NTT(板子整理)

思路来源

https://www.cnblogs.com/candy99/p/6641972.html

FTT板子整理

//fft
#include 
#include 
#include 
#include 
#include 
using namespace std;
typedef long long ll;
const int N=(1<<18)+5, INF=1e9;
const double PI=acos(-1);
inline int read(){
    char c=getchar();int x=0,f=1;
    while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
    while(c>='0'&&c<='9'){x=x*10+c-'0';c=getchar();}
    return x*f;
}

struct meow{
    double x, y;
    meow(double a=0, double b=0):x(a), y(b){}
};
meow operator +(meow a, meow b) {return meow(a.x+b.x, a.y+b.y);}
meow operator -(meow a, meow b) {return meow(a.x-b.x, a.y-b.y);}
meow operator *(meow a, meow b) {return meow(a.x*b.x-a.y*b.y, a.x*b.y+a.y*b.x);}
meow conj(meow a) {return meow(a.x, -a.y);}
typedef meow cd;

struct FastFourierTransform {
    int n, rev[N];
    cd omega[N], omegaInv[N];
    void ini(int lim) {
        n=1; int k=0;
        while(n>1]>>1) | ((i&1)<<(k-1));
        
        for(int k=0; k>1;
            for(cd *p=a; p!=a+n; p+=l) 
                for(int k=0; k=0; i--) printf("%d",c[i]);
}

NTT板子整理

//ntt
#include 
#include 
#include 
#include 
#include 
using namespace std;
typedef long long ll;
const int N=(1<<18)+5, INF=1e9;
const double PI=acos(-1);
inline int read(){
    char c=getchar();int x=0,f=1;
    while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
    while(c>='0'&&c<='9'){x=x*10+c-'0';c=getchar();}
    return x*f;
}

ll P=1004535809;
ll Pow(ll a, ll b,ll P) {
    ll ans=1;
    for(; b; b>>=1, a=a*a%P)
        if(b&1) ans=ans*a%P;
    return ans;
}
struct NumberTheoreticTransform {
    int n, rev[N];
    ll g;
    void ini(int lim) {
        g=3;
        n=1; int k=0;
        while(n>1]>>1) | ((i&1)<<(k-1));
    }
    void dft(ll *a, int flag) {
        for(int i=0; i>1;
            ll wn = Pow(g, flag==1 ? (P-1)/l : P-1-(P-1)/l, P);
            for(ll *p=a; p!=a+n; p+=l) {
                ll w=1;
                for(int k=0; k=0; i--) printf("%d",c[i]);
}

 

你可能感兴趣的:(知识点总结)