高精度
code here
:::info[框架 + 使用说明]
namespace bignum
{
namespace ntt
namespace fft
namespace choose//选择ntt/fft
typedef long long LL;
const LL base = 1e9,bs = 9,nttorfft = 0,multp = 0,divtp = 0,gcdtp = 0,mullim = 1e5;
//base:压位进制
//bs:压的位数
//nttorfft:0ntt 1fft
//multp:0自动 1朴素 2ntt/fft
//divtp:0自动(目前唯一倍增除法,ntt/fft没写)
//gcdtp:0自动(正数时二进制优化的更相减损) 1辗转相除
//mullim:ntt/fft的阈值
struct bigint
{
bool flag;
vector<LL> x;
bigint()
{
flag = 0,x.clear();
}//未初始化为 0
void init(string str)
bigint(string s)
bigint(const LL &num)
void check()//-0
string print()
friend ostream& operator << (ostream &out,const bigint &x)
friend istream& operator >> (istream &in,bigint &x)
friend bool operator >= (const bigint &a,const bigint &b)
friend bool operator == (const bigint &a,const bigint &b)
friend bool operator != (const bigint &a,const bigint &b)
friend bool operator <= (const bigint &a,const bigint &b)
friend bool operator > (const bigint &a,const bigint &b)
friend bool operator < (const bigint &a,const bigint &b)
friend bigint abs(const bigint &a)
friend bigint uadd(const bigint &a,const bigint &b)
void mul2()
void div2()
friend bigint muls(const bigint &b,const LL &k)
friend bigint divs(const bigint &b,const LL &k)
friend bigint mods(const bigint &b,const LL &k)
friend bigint usub(const bigint &a,const bigint &b)
friend bigint umul0(const bigint &a,const bigint &b)//朴素乘法
friend bigint operator + (const bigint &a,const bigint &b)
friend bigint operator - (const bigint &a,const bigint &b)
friend bigint operator - (const bigint &a)
friend bigint operator + (const bigint &a)
friend bigint operator * (const bigint &a,const bigint &b)
friend bigint operator * (const bigint &a,const LL &b)
friend bigint operator * (const LL &b,const bigint &a)
friend bigint operator / (const bigint &a,const LL &b)
friend bigint operator % (const bigint &a,const LL &b)
friend bigint udiv(const bigint &a,const bigint &b)//倍增除法
friend bigint umod(const bigint &a,const bigint &b)//倍增除法
friend bigint operator / (const bigint &a,const bigint &b)
friend bigint operator % (const bigint &a,const bigint &b)
friend bigint operator ^ (const bigint &a,const bigint &b)//幂
friend bigint qmi(const bigint &a,const bigint &b,const bigint &mod)//取模幂
friend bigint gcd0(const bigint &a,const bigint &b)//辗转相除
friend bigint gcd1(const bigint &a,const bigint &b)//二进制gcd
friend bigint gcd(const bigint &a,const bigint &b)
friend bigint operator += (bigint &a,const bigint &b)
friend bigint operator -= (bigint &a,const bigint &b)
friend bigint operator *= (bigint &a,const bigint &b)
friend bigint operator /= (bigint &a,const bigint &b)
friend bigint operator %= (bigint &a,const bigint &b)
friend bigint operator *= (bigint &a,const LL &b)
friend bigint operator /= (bigint &a,const LL &b)
friend bigint operator %= (bigint &a,const LL &b)
friend bigint sqrt(const bigint &n,const bigint &m = 2)
explicit operator LL()
explicit operator int()
explicit operator bool()
};
struct bigfrac;//大分数,没什么高级的
}
::: https://www.luogu.com.cn/article/uc9ih54g