Cod sursa(job #1607810)

Utilizator GeorgeCalinPetruta George-Calin GeorgeCalin Data 21 februarie 2016 16:58:19
Problema Suma si numarul divizorilor Scor 70
Compilator cpp Status done
Runda Arhiva educationala Marime 1.68 kb
#include <iostream>
#include <cstdio>
#include <cmath>
using namespace std;
#define SIZE 1000003
#define MODULO 9973

bool fr[SIZE];
int v[75000];

int powi(int x, int pow){
int s=1;
for(int i=0;i<pow;i++){
    s*=x;
}
return s;
}
int main()
{
    int s,con,c,d,conj,srt,l,m,n,t;
    long long cd,x;
    freopen("ssnd.in","r",stdin);
    freopen("ssnd.out","w",stdout);
    scanf("%d ",&t);
    fr[2]=0;
    int sqrtSize=sqrt(SIZE);
    for(int i=2; i<=sqrtSize; i++)
    {
        if(fr[i]==0)
        {
            con=2;
            d=i;
            s=d*con;
            while(s<=SIZE)
            {
                fr[s]=1;
                s=d*con;
                con++;
            }
        }
    }
    c=0;
    int u=0;
    for(long i=2; i<=1000000; i++)
    {
        if(fr[i]==0)
        {
            c++;
            u++;
            v[u]=i;
        }
    }
    for(int i=1; i<=t; i++)
    {
        scanf("%lld ",&x);
        conj=1;
        double b=x;
        srt=sqrt(b);
        srt+=2;
        s=1;
        cd=1;
        while(v[conj]<=srt )
        {
            con=0;
            while(x%v[conj]==0)
            {
                con++;
                x=x/v[conj];
            }
            cd=cd*(con+1);

            n=powi(v[conj],con+1)-1;
            m=v[conj]-1;
            l=n/m;

            s=s*l;
            if(s>MODULO){
                s%=MODULO;
            }
            conj++;
        }
        if(x>1){
            cd*=2;
            s*=((x*x)-1)/(x-1);
             if(s>MODULO){
                s%=MODULO;
            }
        }
        printf("%lld %d\n",cd,s);
    }
    return 0;
}