Cod sursa(job #2174722)

Utilizator MDiana15Diana M MDiana15 Data 16 martie 2018 13:08:59
Problema Suma si numarul divizorilor Scor 70
Compilator cpp Status done
Runda Arhiva educationala Marime 0.83 kb
#include <fstream>
#define MOD 9973
using namespace std;
ifstream f("ssnd.in");
ofstream g("ssnd.out");
bool ciur[1000010];
long long i,j,d,x,nr,sum,s,p,n;
int main()
{
     for(d=2;d*d<=1000000;d++)
        if(ciur[d]==0)
          for(i=d*d;i<=1000000;i=i+d)ciur[i]=1;
    ciur[0]=1;
    ciur[1]=1;
     f>>n;
     sum=1;
     for(i=1;i<=n;i++)
     {
        f>>x;
        nr=1;
        sum=1;
        for(d=2;d*d<=x;d++)
        {
        if(ciur[d]==0)
        {
        if(x%d==0)
        {p=1;
        s=d;
        while(x%d==0)
        {
        p++;
        s=(s*d);
        x=x/d;
        }
        sum=(sum*(s-1)/(d-1))%MOD;
        nr=nr*p;
        }
        }
        }
        if(x>1){sum=sum*((x*x-1)/(x-1))%MOD;nr=nr*2;
              }
       g<<nr<<" "<<sum<<'\n';
     }
    return 0;
}