## AMR10C Statement

You all know about factorization of an integer. Here we want you to factor a number into as few factors as possible. That is easy, you say, just have the number itself, and that will be the smallest number of factors i.e. 1.

But wait, I haven’t finished — each of the factors that you find must be square-free. A square-free number, however you factor it, won’t have any factor that is a perfect square. Of course, you can never include 1 as a factor.

### Input

The first line of input is the number of test cases T.

The next T lines each have an integer N.

### Output

For each testcase, output the smallest number of square-free factors.

### Constraints

T <= 10^{4}

2 <= N <= 10^{6}

## AMR10C Solution

0 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 |
#include <iostream> #include <cstdio> #include <cstdlib> #include <cmath> #include <cstring> #include <numeric> #include <algorithm> #include <functional> #include <vector> #include <queue> #include <set> #include <map> //#include <unordered_map> #include <utility> #include <cassert> #include <iomanip> #include <ctime> #include <sstream> #include <istream> #include <stdio.h> #include <stdlib.h> using namespace std; const int me = 1000025; int T, N; int lp[me]; int main() { ios_base::sync_with_stdio(0); cin.tie(0); for(int i = 2; i < me; i ++) if(!lp[i]){ for(int j = i; j < me; j += i) lp[j] = i; } cin >> T; for(int _ = 0; _ < T; _ ++){ cin >> N; int result = 0; while(N > 1){ int d = lp[N]; int count = 0; while(N % d == 0){ count ++; N /= d; } result = max(result, count); } cout << result << endl; } return 0; } |

**You may also like**