Cod sursa(job #2015518)

Utilizator workwork work work Data 26 august 2017 15:18:59
Problema Suma si numarul divizorilor Scor 70
Compilator cpp Status done
Runda Arhiva educationala Marime 1.08 kb
#include <bits/stdc++.h>

using namespace std;

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

int t, p[1000005], k, c[1000005];
const int MOD = 9973;

long long put(long long x, int e)
{
    long long rez = 1;
    for(int i = 1; i <= e; ++i) rez *= x;
    return rez;
}

int main()
{
    F >> t;
    for(int i = 2; i<= 1000000; ++ i)
        if(!c[i])
        {
            p[++k] = i;
            for(int j = i+i; j <= 1000000; j += i) c[j] = 1;
        }
    while(t--)
    {
        long long x;
        F >> x;
        if(x == 1)
        {
            G << 1 << " " << 1 << '\n';
            continue;
        }
        int j = 1, e; long long nrd = 1, s = 1;
        while(1LL*p[j]*p[j]<=x)
        {
            e = 0;
            while(x % p[j] == 0) x /= p[j], e++;
            if(e>0)
            {
                nrd *= (e+1);
                s = (s*(put(p[j], e+1)-1)/(p[j]-1))%MOD;
            }
            j++;
        }
        if(x > 1) nrd*=2, s = (s*(put(x, 2)-1)/(x-1))%MOD;
        G << nrd << " " << s << '\n';
    }
    return 0;
}