Cod sursa(job #1524936)

Utilizator alittlezzCazaciuc Valentin alittlezz Data 14 noiembrie 2015 16:10:30
Problema Suma si numarul divizorilor Scor 10
Compilator cpp Status done
Runda Arhiva educationala Marime 1.22 kb
#include <bits/stdc++.h>
#define pb push_back

using namespace std;

const int m = 9973;

long long lgput(int b, int e){
    long long sol = 1;
    while(e){
        if(e&1){
            sol = (sol*b)%m;
        }
        b = (b*b)%m;
        e >>= 1;
    }
    return sol;
}

int main()
{
    int t,test,d,c;
    long long sum,nr,n;
    freopen("ssnd.in", "r", stdin);
    freopen("ssnd.out", "w", stdout);
    scanf("%d",&t);
    for(test = 1;test <= t;test++){
        scanf("%lld",&n);
        nr = 1;
        sum = 1;
        if(n%2 == 0){
            c = 0;
            while(n%2 == 0){
                n >>= 1;
                c++;
            }
            nr *= (c+1);
            sum = (sum *1LL*(lgput(2,c+1)-1))%m;
        }
        for(d = 3;1LL*d*d <= n;d += 2){
            if(n%d == 0){
                c = 0;
                while(n%d == 0){
                    c++;
                    n /= d;
                }
                nr *= (c+1);
                sum = (sum*1LL*(lgput(d,c+1)-1)/(d-1))%m;
            }
        }
        if(n > 1){
            nr *= 2;
            sum = (sum*1LL*(n+1))%m;
        }
        printf("%lld %lld\n",nr,sum);
    }
    return 0;
}