<p>Given an integer array <code>nums</code>, return <em>the sum of divisors of the integers in that array that have exactly four divisors</em>. If there is no such integer in the array, return <code>0</code>.</p>

<p>&nbsp;</p>
<p><strong class="example">Example 1:</strong></p>

<pre>
<strong>Input:</strong> nums = [21,4,7]
<strong>Output:</strong> 32
<strong>Explanation:</strong> 
21 has 4 divisors: 1, 3, 7, 21
4 has 3 divisors: 1, 2, 4
7 has 2 divisors: 1, 7
The answer is the sum of divisors of 21 only.
</pre>

<p><strong class="example">Example 2:</strong></p>

<pre>
<strong>Input:</strong> nums = [21,21]
<strong>Output:</strong> 64
</pre>

<p><strong class="example">Example 3:</strong></p>

<pre>
<strong>Input:</strong> nums = [1,2,3,4,5]
<strong>Output:</strong> 0
</pre>

<p>&nbsp;</p>
<p><strong>Constraints:</strong></p>

<ul>
	<li><code>1 &lt;= nums.length &lt;= 10<sup>4</sup></code></li>
	<li><code>1 &lt;= nums[i] &lt;= 10<sup>5</sup></code></li>
</ul>

vector<bool> vec(100003, 1);
vector<long long> primes;
unordered_map<long long, pair<long long,long long>> MAP;
struct precalc
{
    precalc()
    {
        ios_base::sync_with_stdio(false);
        cin.tie(NULL);
        vec[1] = 0;
        vec[0] = 0;
        for(long long i = 2; i<100003; i++)
        {
            if(vec[i])
            {
                for(long long p = i*i; p<100003; p+=i)
                {
                    vec[p] = 0;
                }
            }
        }
        
        for(long long i=0; i<100003; i++)
        {
            if(vec[i]) primes.push_back(i);
        }
        long long p = primes.size();
        for(long long i = 0; i<p; i++)
        {
            for(long long j = i+1; j<p; j++)
            {
                if(primes[i]*primes[j] <= 100000 )
                {
                    MAP[primes[i]*primes[j]] = {primes[i], primes[j]};
                }
                else break;
            }
            MAP[primes[i]*primes[i]*primes[i]] = {primes[i], primes[i]*primes[i]};
        }
    }
};

precalc go;


class Solution {
public:
    int sumFourDivisors(vector<int>& nums) {
        
        long long ans = 0;
        for(auto &it: nums)
        {
            if(MAP.count(it))
            {
                ans += 1 + it + MAP[it].first + MAP[it].second;
            }
        }
        return ans;
        
    }
};
19400