Cod sursa(job #1319592)

Utilizator alexman262Belbu Alexandru Marian alexman262 Data 17 ianuarie 2015 10:43:59
Problema Suma si numarul divizorilor Scor 70
Compilator cpp Status done
Runda Arhiva educationala Marime 1.13 kb
#include<fstream>
using namespace std;
ifstream fin("ssnd.in");
ofstream fout("ssnd.out");
int main()
{
    long long y,z,p,d,e,S,x,C,a,i,M,t;
    M=9973;
    fin>>t;
    for(i=1;i<=t;i++)
    {
        fin>>a;
        C=1;
        S=1;
        x=a;
        d=2;
        while(d*d<=x)
        {
            if(x%d==0)
            {
                e=0;
                while(x%d==0)
                {
                    e=e+1;
                    x=x/d;
                }
                C=C*(e+1);
                p=1;
                y=d;
                z=e+1;
                while(z!=0)
                {
                    if(z%2==1)
                    {
                        p=p*y;
                    }
                    y=y*y;
                    z=z/2;
                }
                S=S*(p-1)/(d-1);
                }
                d=d+1;
            }
            if(x>1)
            {
                C=C*2;
                S=S*(x+1);
            }
            fout<<C<<" "<<S%M<<"\n";
        }

            fin.close();
            fout.close();
            return 0;
}