怎么连 1014 以内因数个数最多都不造。
in:
10
97821761637600
97821761637600
97821761637600
97821761637600
97821761637600
97821761637600
97821761637600
97821761637600
97821761637600
97821761637600
out:
902137
902137
902137
902137
902137
902137
902137
902137
902137
902137
以下代码会 TLE:
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int t;
ll res, n;
void check(ll x) {
ll a = n / x, tmp = __gcd(x, a);
while (tmp > 1)
x /= tmp, tmp = __gcd(x, a);
for (ll i = 1; i * i <= x; i++) {
if (x % i != 0)
continue;
if (i < a)
res++;
if (i * i != x && x / i < a)
res++;
if (i >= a && x / i >= a)
break;
}
}
int main() {
ios::sync_with_stdio(0), cin.tie(0);
cin >> t;
while (t --) {
cin >> n;
res = 0;
for (ll i = 1; i * i <= n; i++) {
if (n % i != 0)
continue;
check(i);
if (i * i != n)
check(n / i);
}
cout << res << '\n';
}
return 0;
}