约数个数

题目描述

给定n个正整数ai,请你输出这些数的乘积的约数个数,答案对1e9+7取模。

输入

第一行包含整数n。

接下来n行,每行包含一个整数aiai

输出

输出一个整数,表示所给正整数的乘积的约数个数,答案需对1e9+7取模。

样例输入 Copy

3
2
6
8

样例输出 Copy

12

提示

1 ≤ n ≤ 100
1 ≤ ai ≤ 2e9
 

解释

#include<iostream>
#include<vector>
#include<algorithm>
#include<unordered_map>
using namespace std;

typedef long long LL;
const int N = 1e9 + 7;

int main()
{
    int n;
    cin >> n;

    unordered_map<LL, LL> arr;

    while (n --)
    {
        LL t;
        cin >> t;
        for (int i = 2; i <= t / i; )
        {
            if (t % i == 0)
            {
                t /= i;
                arr[i] ++;
                continue;
            }
            i++;
        }

        if (t > 1) arr[t] ++;
    }

    LL res = 1;
    for (auto i : arr) res = res * (i.second + 1 ) % N;

    cout << res << endl;

    return 0;
}

 

posted @ 2022-03-01 20:37  ora12321  阅读(11)  评论(0)    收藏  举报