Cod sursa(job #2458305)
| Utilizator | Data | 20 septembrie 2019 10:29:17 | |
|---|---|---|---|
| Problema | Suma si numarul divizorilor | Scor | 0 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva educationala | Marime | 1.01 kb |
#include <fstream>
using namespace std;
ifstream fin("ssnd.in");
ofstream fout("ssnd.out");
bool ciur[1000000];long long m,d,i,v[80000],n,x,t,s,p,j,t1;
int main()
{
for(d=2;d<=1000000;d++)
{
if(ciur[d]==0)
{
v[++m]=d;
for(i=d*d;i<=1000000;i+=d)
ciur[i]=1;
}
}
fin>>n;
for(i=1;i<=n;i++)
{
fin>>x;
j=1;
t=1;
t1=1;
s=1;
while(v[j]*v[j]<=x&&x>1)
{
p=0;
while(x%v[j]==0)
{
p++;
x/=v[j];
t1*=v[j];
}
if(p!=0)
{
t*=p+1;
s*=(t1*v[j]-1)/(v[j]-1);
// fout<<x<<" "<<j<<" "<<v[j]<<" "<<s<<" "<<t1<<endl;
}
j++;t1=1;
}
if(x>1)
{
t*=2;
s*=(x*x-1)/(x-1);
}
fout<<t<<" "<<s<<'\n';
}
return 0;
}
