Cod sursa(job #2164064)

Utilizator nicolaefilatNicolae Filat nicolaefilat Data 12 martie 2018 21:19:30
Problema Suma si numarul divizorilor Scor 10
Compilator cpp Status done
Runda Arhiva educationala Marime 0.79 kb
#include <iostream>
#include <fstream>
#define MODULO 9973

using namespace std;

ifstream in("ssnd.in");
ofstream out("ssnd.out");

int nr_diviz,suma;

void rez(int n){
    int d = 2,exp = 0,copie = n;
    nr_diviz = 1,suma = n+1;
    while(d*d <= n){
        exp = 0;
        while(n % d == 0){
            n /= d;
            exp++;
        }
        if(exp > 0)
            nr_diviz *= (exp+1);
        d++;
    }
    if(n > 1)
        nr_diviz *= 2;
    n = copie;
    for(d = 2; d * d < n; d++)
        if(n % d == 0)
            suma += n/d + d;
    if(d * d == n)
        suma += d;
}


int main()
{
    int t,nr;
    in>>t;
    for(int i = 0; i < t; i++){
        in>>nr;
        rez(nr);
        out<<nr_diviz<<" "<<suma<<"\n";
    }
    return 0;
}