
https://www.acwing.com/problem/content/description/873/
#include<cstdio>
#include<iostream>
#include<map>
using namespace std;
typedef long long int LL;
const int mod=1e9+7;
map<int,int> mp;
void f(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(void)
{
int n; cin>>n;
while(n--)
{
int x; cin>>x;
f(x);
}
LL sum=1;
for(map<int,int>::iterator it=mp.begin();it!=mp.end();it++)
{
int a=it->first,b=it->second;
LL temp=1;
for(int i=1;i<=b;i++)
{
temp=(temp*a+1)%mod;
}
sum=(sum*temp)%mod;
}
cout<<sum<<endl;
return 0;
}
#include<bits/stdc++.h>
using namespace std;
map<int,int> mp;
const int mod=1e9+7;
void f(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(void)
{
int n; cin>>n;
while(n--)
{
int x; cin>>x; f(x);
}
long long int sum=1;
for(auto i=mp.begin();i!=mp.end();i++)
{
int a=i->first,b=i->second;
long long int temp=0;
for(int j=0;j<=b;j++) temp=(temp*a+1)%mod;
sum=(sum*temp)%mod;
}
cout<<sum<<endl;
return 0;
}
679

被折叠的 条评论
为什么被折叠?



