zZ的blog http://blog.csdn.net/ssssssay/article/details/52102173
/*
~~~~~~~~~~~~~~wine~~~~~~~~~~~~~~~
压位高精模板ver 1.1,不滋瓷负数
欢迎指出bug
蒟蒻不会fft和牛顿迭代,效率不高
2017-4-10
eg :
BUGNUM a = 233,b(0),t; LL x,p;
t.init(); t.out();
t = t+1000; t = a+b; t = a-b; t = a/b; t = a%b;
t = a.sqrt(); t = q.pow(x); t = q.pow_mod(x,p);
bool cmp = a>b; //......
p = a._mod(x); p = a._div(x); p = a._add(x);p = a._mul(11);
p = a._add(-23); //减成负数就zZ了
a.div(233); a.add(23); a.mul(2333)
即 a = a/233; a = a+233; a = a*2333;
*/
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <iostream>
using namespace std;
#define ll "lld"
typedef long long LL;
const int BASE = 100000000,MAXLEN = 10330; //高精度 压8位
char s[MAXLEN<<3];
struct BIGNUM {
int len; LL bt[MAXLEN];
void upzero(){
while(!bt[len] && len!=1)--len;} //去前导0
void upbit() {
//进位
LL x(0);
for (int i = 1; i <= len; i++) {
if(bt[i] < 0) {
bt[i] += BASE; --bt[i+1];}
bt[i] += x; x = bt[i]/BASE; bt[i] %= BASE;
}
while(x) bt[++len] = x % BASE,x /= BASE;
}
LL to_long(){
return len<3?bt[2]*BASE+bt[1]:-1;}
BIGNUM(LL num):len(1) {
memset(bt,0,sizeof bt);bt[1]=num;upbit();} //构造函数
BIGNUM():len(1){
memset(bt,0,sizeof bt);}
BIGNUM operator = (LL x) {
len = 1;memset(bt,0,sizeof<