【数所有因子和快速新解/范围亲密数/分解因式怎么去掉重复项】2022-10-31
缘由这个提交到oj上显示时间超限,我觉得代码应该没有问题-编程语言-CSDN问答
int 数所有因子和快速新解(int n)
{//适用所有求因子的应用这里求出含1和自身的和,应用时可减去1或自身或1和自身都减去。int h = 0, c = 0, s = 0;while (++c <= (s = n / c))if (n%c == 0)h += c + (s != c ? s : 0); else;return h;
}int a = 1, b = 1, n = 0;cin >> n;//范围亲密数while (a < n){if ((数所有因子和快速新解(a) - a) == b&&(数所有因子和快速新解(b) - b) == a && a != b) cout << a << "-" << b << "\n"; else;if (++b > n)++a, b = 0;}
void 范围内亲密数对()
{//缘由https://ask.csdn.net/questions/7825921int a = 2, b = 2, n = 0, bb = 0;cin >> a >> n;//范围亲密数while (a < n){if ((数所有因子和快速新解(a) - a) == b && (数所有因子和快速新解(b) - b) == a && a != b)cout << a << "-" << b << "\n", a += 800, b += bb += 800; else;//跳跃式减少运算时间if ((b += 2) > n)a += 2, b = bb;}
}
缘由用C语言分解因式怎么去掉重复项-编程语言-CSDN问答
void 整数所有因子()
{//缘由https://ask.csdn.net/questions/7834376long long n = 0, h = 0, x = 0;std::cin >> n;while (n >= ++x*x)if (n%x == 0)h += x + (n / x > x ? n / x : 0), std::cout << x << " " << n / x << "\n"; else;std::cout << h << "\n";
}