Cod sursa(job #2394720)
| Utilizator | Data | 1 aprilie 2019 20:42:13 | |
|---|---|---|---|
| Problema | Suma si numarul divizorilor | Scor | 0 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva educationala | Marime | 0.84 kb |
#include <bits/stdc++.h>
using namespace std;
ifstream f("ssnd.in");
ofstream g("ssnd.out");
const long long N=1000000000000;
long long s;
long long n,a,x;
long long prim(long long x)
{
int e=1,rez=1,s=0,y=x;
for(int d=2; d*d<=x; d++)
if(x%d==0)
{
s+=d;
s+=x/d;
e=1;
while(y%d==0)
{
e++;
y/=d;
}
rez*=e;
}
if(y>1)
rez*=2;
return rez;
}
int main()
{
f>>n;
for(int i=1; i<=n; i++)
{
s=0;
f>>x;
s++;
s+=x;
g<<prim(x)<<' ';
for(int d=2; d*d<=x; d++)
if(x%d==0)
{
s+=d;
s+=x/d;
}
g<<s<<'\n';
}
return 0;
}
