{
// tmp表示大整数10^N
tmp = one;
LeftShift(tmp, i);
// 如果数组没有和tmp同余的数,则添入
if (rem[j].len == 0)
rem[j] = tmp;
for (k=1; k
// 遍历余数信息数组,若新产生出余数不同的数,则添入
int u = (j+k)%N;
// 为了防止刚加入的10^N被计算,加入条件rem[k].len <= i
if (rem[k].len && rem[k].len <= i
&& rem[u].len == 0)
Plus(tmp, rem[k], rem[u]);
break;
}
} www.2cto.com
Str2HP(str, tmp);
cout << "N*M: ";
PrintHP(rem[0]);
HP d;
Divide(rem[0], tmp, tmp, d);
cout << endl << "M: ";
PrintHP(tmp);
cout << endl;
}
}
作者:linyunzju