we are given a rooted tree that contains 1 to N nodes. The root of the tree is node 1.

each node has some value assigned to it.

we have to find the divisor power

divisor power = Sigma(D[A[i]) * C(i,A[j]))

D(x) = no of divisor of X for ex D(6) = 4

C(i,A[j]) = no of occurance of A[j] in subrtee of node i

where j is an arbitrary node of subtree i

our task is to find the divisor power of each node

2<=n<=100000

1<=A[i]<=100000

1<=x<=y<n

5

10 10 4 4 12

1 2

2 3

2 4

3 5

out = 34 22 9 3 6

below is my code

```
#include<bits/stdc++.h>
using namespace std;
vector<int> adj[100005];
vector<int> mapper[100005];
int arr[100005];
void findDivisors(int n, long long int *div)
{
for (int i = 1; i <= n; i++) {
for (int j = 1; j * i <= n; j++)
div[i * j]++;
}
}
vector<int> dfs(int node , int par)
{
vector<int>x;
x.push_back(node);
for (auto child : adj[node])
{
if (child != par)
{
vector<int>ans = dfs(child , node);
for (auto i : ans)
x.push_back(i);
}
}
mapper[node] = x;
return x;
}
int main()
{
#ifndef ONLINE_JUDGE
freopen("input.txt" , "r" , stdin);
freopen("output.txt" , "w" , stdout);
#endif
int n;
cin >> n;
long long int *div = new long long int[1000006];
int z = 1000006;
findDivisors(z, div);
for (int i = 1; i <= n; ++i)
{
cin >> arr[i];
}
int t = n;
n = n - 1;
while ( n--)
{
int x;
int y;
cin >> x >> y;
adj[x].push_back(y);
adj[y].push_back(x);
}
vector<int> x = dfs(1, 0);
// vector<pair<int, int>> temp[100005];
// int c[t + 1][100000];
int **c = new int*[t + 1];
for (int i = 0; i < t + 1; i++)
{
c[i] = new int[1000005];
}
// for (int i = 1; i < t; i++)
// {
// for (int j = 0; j < 100000; j++)
// {
// c[i][j] = 0;
// }
// }
for (int i = 1; i <= t; i++)
{
// vector<pair<int, int>>x;
for (auto ele : mapper[i])
{
// sum+=(div[ele] * )
// c[i][e] = arr[ele]
c[i][arr[ele]]++;
}
}
// temp[i] = x;
for (int i = 1; i <= t; i++)
{
int sum = 0;
for (auto ele : mapper[i])
{
// cout << arr[ele] << endl;
// cout << div[arr[ele]] << " " << c[i][arr[ele]] << endl;
sum += (div[arr[ele]] * c[i][arr[ele]]);
}
cout << sum << " ";
}
}
```

I am not that good with complexity and this question was asked to me yesterday for a placement round which is over now i couldnt able to solve it that time but i tried it now and i got the right answer just want to know whether it is within constraints or not

If anyone have better solution please mention