Cod sursa(job #2416817)

Utilizator andreisontea01Andrei Sontea andreisontea01 Data 28 aprilie 2019 12:14:02
Problema Suma si numarul divizorilor Scor 70
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 1.08 kb
#include <bits/stdc++.h>

using namespace std;

bool ciur[1000005];
vector<int> prim;

int main()
{
    ifstream fin("ssnd.in");
    ofstream fout("ssnd.out");
    int t;
    fin >> t;
    for(int i = 2; i <= 1000000; ++i){
        if(!ciur[i]){
            prim.push_back(i);
            for(int j = 2 * i; j <= 1000000; j += i)
                ciur[i] = 1;
        }
    }
    while(t){
        long long n;
        fin >> n;
        int d = 0, exp = 0, cnt = 1;
        long long put = 1, sum = 1;
        while(1LL * prim[d] * prim[d] <= n && d < int(prim.size())){
            put = 1LL;
            exp = 0;
            while(n % prim[d] == 0){
                n /= prim[d];
                put *= prim[d];
                exp++;
            }
            put *= prim[d];
            cnt *= (exp + 1);
            sum *= (put - 1) / (prim[d] - 1);
            d++;
        }
        if(n > 1){
            cnt *= 2;
            sum *= (n * n - 1) / (n - 1);
        }
        fout << cnt << " " << sum % 9973 << "\n";
        t--;
    }
    return 0;
}