Cod sursa(job #1644809)

Utilizator andreizZenoveiov Andrei andreiz Data 10 martie 2016 09:37:04
Problema Suma si numarul divizorilor Scor 0
Compilator cpp Status done
Runda Arhiva educationala Marime 0.82 kb
#include<iostream>
#include <fstream>

using namespace std;

ifstream f("ssnd.in");
ofstream g("ssnd.out");

long long n;
int t;
const int m=9973;
void rez()
{
    int d;
    f>>n;
    int s=1,nr=1;

    for(d=2;n>1;++d)
        {
        if(1LL*d*d >n)
            n=-1;
        int nrc=0;
        int act_prod=1,act_sum=1;

        while(n%d==0)
            {
            act_prod*=d;
            act_prod%=m;
            act_sum+=act_prod;
            if(act_sum>m)
                act_sum-=m;

            n/=d;
            ++nrc;
        }

        s*=act_sum;
        s%=m;
        nr*=(nrc+1);
    }

    if(n!=1)
        {
        nr*=2;
        s=(1LL*s*(n+1)%m);
        }

    g<<nr<<' '<<s<<'\n';
}

int main()
{
int i;
f>>t;
for(i=1;i<=t;i++)
    rez();
return 0;
}