缘由https://bbs.csdn.net/topics/603462686 类似https://blog.csdn.net/xianfajushi/article/details/115666759
long long 快速近积数(long long 数) { long long m = 1, j = 数; while (j > m)m *= 10, j /= 10; if (!j)j = m; while (m /= 2) { while (j * j > 数)j -= m; while (j * j < 数)j += m; } return (j * j > 数 ? --j : j); } long long a = 1; while (a <= 10000000000) cout << a << "=" << 快速近积数(a) << "t", a += a; 可用于开平方,小数4位要加双倍的0,如7开平方 long long a = 700000000; std::cout << (a = 快速近积数(a)) << "t" << a*a << std::endl;
void 质数乘积() {//缘由https://bbs.csdn.net/topics/603462686 long long a = 7140229933, z = 1, s = a / z; while ((z += 2) <= (s = a / z)) if (质数判断(z) && 质数判断(s) && s * z == a) //if (z == 整数逆序(z) || s == 整数逆序(s)) std::cout << z << "t" << s << "n"; } void 质数乘积() {//缘由https://bbs.csdn.net/topics/603462686 long long a = 7140229933, z = a, s = 0; z = 快速近积数(z); std::cout << z << "快速近积数tn"; if (!(z % 2))--z; while ((z -= 2) <= (s = a / z)) if (质数判断(z) && 质数判断(s) && s * z == a) //if (z == 整数逆序(z) || s == 整数逆序(s)) std::cout << z << "t" << s << "n", z = 0; }
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)