Cod sursa(job #2162224)

Utilizator constantin.gabrielConstantin Gabriel constantin.gabriel Data 12 martie 2018 09:15:27
Problema Suma si numarul divizorilor Scor 60
Compilator cpp Status done
Runda Arhiva educationala Marime 0.8 kb
#include <iostream>
#include <fstream>
using namespace std;
ifstream f("ssnd.in");
ofstream g("ssnd.out");
int t;
long long n, s, nr;
int putere(int x,int y)
{
    int constanta=x;
    for(int j=1;j<=y;j++)
        x*=constanta;
    x-=1;
    return x/(constanta-1);
}
int main()
{
    f >> t;
    for (int i = 1; i <= t; i++)
    {
        f >> n;
        s = 1;
        nr = 1;
        int d = 2,p;
        while (n > 1)
        {
            p = 0;
            while (n % d == 0)
            {
                ++p;
                n /= d;
            }
            if (p)
                {
                    nr*=(p+1);
                    s*=putere(d,p);
                }
            ++ d;
        }
        //cout<<s<<endl;
        g<<nr<<' '<<s%9973<<endl;
    }
}