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
| #include <stdio.h> #include <math.h>
void primeFactorization(long long n, int threshold) { long long ans = 1; for (long long i = 2; i <= sqrt(n); i++) { long long sum = 1; if (n % i == 0) { int count = 0; while (n % i == 0) { count++; n /= i; }
if (count >= threshold) sum = pow(i, count); ans *= sum; } } printf("%lld\n", ans);
}
int main() { long long num; int threshold; int q; scanf("%d", &q);
for (int i = 1; i <= q; i++) { scanf("%lld%d", &num, &threshold); primeFactorization(num, threshold); }
return 0; }
|