#include using namespace std; vector factors(long n){ int z = 2; long i = n; vector res; res.push_back((long) 1); // Print the number of 2s that divide n while (i%2 == 0) { res.push_back((long) 2); i = i/2; } // n must be odd at this point. So we can skip // one element (Note j = j +2) for (int j = 3; j <= sqrt(i); j = j+2) { // While j divides i, print j and divide i while (i%j == 0) { res.push_back((long) j); i = i/j; } } // This condition is to handle the case when n // is a prime number greater than 2 if (i > 2){ res.push_back((long) i); } res.pop_back(); return res; } long longestSequence(vector a, int n) { // Return the length of the longest possible sequence of moves. long res = 0; for (int i=0;i f; long n = a[i]; f = factors(n); for (int j=0;j> n; vector a(n); for(int a_i = 0; a_i < n; a_i++){ cin >> a[a_i]; } long result = longestSequence(a, n); cout << result << endl; return 0; }