Cod sursa(job #2949778)

Utilizator Theo8338Theodor Sandu Theo8338 Data 1 decembrie 2022 17:55:48
Problema Suma si numarul divizorilor Scor 40
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.84 kb
#include <bits/stdc++.h>
using namespace std;
ifstream fin("ssnd.in");
ofstream fout("ssnd.out");
int putere(int d , int p)
{
    int s = 1;
    while(p)
    {
        if(p % 2 == 1)
            s = s * d;
        d = d * d;
        p /= 2;
    }
    return s;
}
void descompunere(int n)
{
    int d=2,nr=1,p;
    unsigned long long s=1;
    while(n > 1)
    {
        p = 0;
        while(n % d == 0)
        {
            p++;
            n /= d;
        }
        if(p)
        {
            nr*=p+1;
            s*=((putere(d,p+1)-1)/(d-1));

        }
        d++;
        if(n>1 && d * d > n)
        {
            d = n;
        }
    }
    fout<<nr<<" "<<s%9973<<'\n';
}
int main()
{
    int t,i,x;
    fin>>t;
    for(i=1;i<=t;i++)
    {
        fin>>x;
        descompunere(x);
    }
    return 0;
}