1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66
|
#include <NTL/ZZXFactoring.h>
NTL_CLIENT
long NumFacs(const vec_pair_ZZX_long& v)
{
long i;
long res;
res = 0;
for (i = 0; i < v.length(); i++)
res += v[i].b;
return res;
}
int main()
{
long cnt = 0;
while (SkipWhiteSpace(cin)) {
cnt++;
cerr << ".";
vec_ZZ w;
ZZX f1, f;
long nfacs;
cin >> w;
cin >> nfacs;
long i, n;
n = w.length();
f.rep.SetLength(n);
for (i = 0; i < n; i++)
f.rep[i] = w[n-1-i];
f.normalize();
vec_pair_ZZX_long factors;
ZZ c;
factor(c, factors, f, 0);
mul(f1, factors);
mul(f1, f1, c);
if (f != f1) {
cerr << f << "\n";
cerr << c << " " << factors << "\n";
TerminalError("FACTORIZATION INCORRECT (1) !!!");
}
long nfacs1 = NumFacs(factors);
if (nfacs1 != nfacs)
TerminalError("FACTORIZATION INCORRECT (2) !!!");
}
cerr << "\n";
cerr << "MoreFacTest OK\n";
return 0;
}
|