#include #include /* sqrt */ using namespace std; long *treeSize; // Function to print the divisors vector getDivisors(long n) { vector divisors; // Note that this loop runs till square root for (long i=1; i<=sqrt(n)+1; i++) { if (n%i==0) { // If divisors are equal, print only one if (n/i == i) { divisors.push_back(i); // printf("%d ", i); } else { // Otherwise print both divisors.push_back(i); // printf("%d %d ", i, n/i); divisors.push_back(n/i); } } } return divisors; } long findTreeSize(long number) { if(number == 1 ) { treeSize[1] = 1; return 1; } if (treeSize[number] != 0) { return treeSize[number]; } else { vector divisorList = getDivisors(number); long max = 0; for(long j=0;j a) { // Return the length of the longest possible sequence of moves. long result = 0; long maxNo = 0; for(int i=0;imaxNo) maxNo = a[i]; } treeSize = new long[maxNo]; vector> aDivisorList(a.size()); for(int i=0;i> n; vector a(n); for(int a_i = 0; a_i < n; a_i++){ cin >> a[a_i]; } long result = longestSequence(a); cout << result << endl; return 0; }