给定n个正整数ai,请你输出这些数的乘积的约数个数,答案对1e9+7取模。
输入格式
第一行包含整数n。
接下来n行,每行包含一个整数ai
输出格式
输出一个整数,表示所给正整数的乘积的约数个数,答案需对1e9+7取模。
数据范围
1≤n≤1001≤n≤100,
1≤ai≤2∗1091≤ai≤2∗109
输入样例:
3
2
6
8
输出样例:
12
#include <bits/stdc++.h> using namespace std; typedef long long ll; const int mod = 1e9+7; int T,x; map<ll,ll> mp;//记录某个质因数出现的次数 void fun(int x){//分解质因数,并记录次数 for(int i = 2;i<=x/i;i++){ while(x%i ==0) x/=i,mp[i]++; } if(x>1) mp[x]++; } int main(){ cin>>T; while(T--){ cin>>x; fun(x); } ll res = 1; for(auto m:mp){ res = (res*(m.second+1))%mod; //公式的应用 } cout<<res<<endl; return 0; }
- 公式的应用--重点
对于一个数计算机出其质因数+每个质因数的个数
p--质因数,a指数