Cod sursa(job #799563)

Utilizator icb_mnStf Cic icb_mn Data 19 octombrie 2012 13:15:39
Problema Suma si numarul divizorilor Scor 70
Compilator cpp Status done
Runda Arhiva educationala Marime 1.16 kb
#include<fstream>
#define LL long long
#define M 9973

using namespace std;

ifstream f("ssnd.in");
ofstream g("ssnd.out");
int t, semn[1000001], ciur[80000];

inline void eratosthenes()
{
    ciur[0] = 2;
    int lng = 0;
    for(int i = 3; i <= 1000000; i += 2)
    {
        if(!semn[i])
        {
            ciur[++lng] = i;
            for(int j = i + i; j + i <= 1000000; j += i)semn[j] = 1;
        }
    }
}

inline void descompune()
{
    LL putere,numar, nr = 1, sum = 1,n;
    int i = 0,d = 0;
    f>>n;

    while(ciur[i] * ciur[i] <= n)
    {
        if(!(n % ciur[i]))
        {
            d = 0;
            LL s = 1;
            putere  =1;
            while(!(n % ciur[i]))
            {
                d++;
                n /= ciur[i];
                putere = putere * ciur[i];
                s += putere;
            }
            sum = (sum * s) % M;
            nr = nr * (1+ d);
        }
        i++;
    }
    if(n > 1)nr = 2 * nr, sum = (sum * (n + 1)) % M;

    g<<nr<<' '<<sum <<'\n';
}
int main()
{

    f>>t;
    eratosthenes();

    while(t--) descompune();

    g.close();

    return 0;
}