Cod sursa(job #615646)

Utilizator theocmtAxenie Theodor theocmt Data 10 octombrie 2011 14:54:06
Problema Suma si numarul divizorilor Scor 0
Compilator cpp Status done
Runda Arhiva educationala Marime 1.24 kb
#include<fstream>

using namespace std;

int n,t,x,p,s,m,y;
bool v[2000000],ok;

ifstream f("ssnd.in");
ofstream g("ssnd.out");
/*
void ciur()
{
    long long i,j;
    for(i=2; i<=1000000; i++)
	{
		if (!v[i])
		{
			for (j=i; j<=1000000; j*=j)
                v[j]=true;
		}
	}
}
*/

void ciur()
{
    int i,nr;
    for(i=2; i<=1000000; i++)
	{
		if (!v[i])
		{
			nr=i;
			while(nr<=1000000)
			{
				nr+=i;
				if (nr<=1000000)
					v[nr]=true;
			}
		}
	}
}

int main()
{
    int i,j;
    f>>t;
    ciur();

    for (j=1; j<=t; j++)
    {
        f>>n;
        m=n;
        p=1;
        s=1;
        ok=false;
        for (i=2; i*i<=n; i++)
        {
            x=0;
            y=1;
            if (!v[i])
            {
                while(m%i==0)
                {
                    m/=i;
                    ++x;
                    y*=i;
                    ok=true;
                }
                p *= (x+1);
                p %= 9973;
                s *= (y*i-1)/(i-1);
                s %= 9973;
            }
        }
        if (ok)
            g << p % 9973 << " " << s % 9973 << "\n";
        else
            g << 2 << " " << (n+1) % 9973 << "\n";
    }
	return 0;
}