Cod sursa(job #822932)

Utilizator UMihneaUngureanu Mihnea UMihnea Data 24 noiembrie 2012 11:39:18
Problema Suma si numarul divizorilor Scor 70
Compilator cpp Status done
Runda Arhiva educationala Marime 1.24 kb
#include <cstdio>
#include <algorithm>
#define M 9973
using namespace std;

long long t,P[1000010],N,i,np,s,q,e,pr;
long long int n,S;
void ciur();

int main()
{
    freopen("ssnd.in","r",stdin);
    freopen("ssnd.out","w",stdout);
    ciur();
    scanf("%lld",&t);
    for(;t;t--)
    {
        scanf("%lld",&n);
        S=1; N=1;
        for(i=1;i<=np&&P[i]*P[i]<=n;i++)
            if(n%P[i]==0)
            {
                s=1; q=1;
                e=1; pr=P[i]%M;
                while(n%P[i]==0)
                {
                    e++;
                    q=(q*pr)%M;
                    s=(s+q)%M;
                    n/=P[i];
                }
                N*=e;
                S=(S*s)%M;
            }
        if(n>1)
        {
            N*=2;n=(n+1)%M;
            S=(S*n)%M;
        }
        printf("%lld %lld\n",N,S);
    }
    return 0;
}
void ciur()
{
    long long k,j;
    P[1]=2;
    np=1;
    for(k=3;k<=1000;k+=2)
        if(P[k]==0)
        {
            np++;
            P[np]=k;
            for(j=k*k;j<=1000000;j+=2*k)
                P[j]=1;
        }
    for(k=1001;k<=1000000;k+=2)
        if(P[k]==0)
        {
            np++;
            P[np]=k;
        }
}