Cod sursa(job #2458248)

Utilizator sabinandreiBocan Sabin Andrei sabinandrei Data 19 septembrie 2019 22:59:08
Problema Suma si numarul divizorilor Scor 70
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 1.25 kb
//
//  main.cpp
//  ssnd
//
//  Created by Sabin Andrei on 9/15/19.
//  Copyright © 2019 Sabin Andrei. All rights reserved.
//

#include <fstream>
#include <iostream>
#include <cmath>

using namespace std;

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


long long cck(long long a, long long b)
{
    long long p=1;
    while (b)
    {
        if (b%2==1) p=p*a;
        b/=2;
        a=a*a;
    }
    return p;
}

bool b[1000009];
unsigned long long n,i,j,m,p[1000009],d,x,nd=1,sd=1,pl,cnt,y;

void cr()
{
    int i,j;
    b[1]=b[0]=1;
    for (i=4; i<=1000000; i+=2)
        b[i]=1;
    for (i=3; i*i<=1000000; i+=2)
        if (b[i]==0)
            for (j=i*i; j<=1000000; j+=2*i)
                b[j]=1;
    cnt=0;
    for (i=1; i<=1000000; i++)
        if (b[i]==0)
            p[++cnt]=i;
}

int main()
{
    in>>n;
    cr();
    for(i=1;i<=n;i++)
    {
        in>>x;
        j=1;
        pl=0;
        nd=1;
        sd=1;
        while(x>1)
        {
            y=p[j];
            pl=1;
            cout<<x<<" "<<y<<endl;
            while(x%y==0)
            {
                x=x/y;
                pl++;
            }
            nd*=pl;
            sd*=((cck(y,pl)-1)/(y-1));
            sd%=9973;
            j++;
        }
        out<<nd<<" "<<sd<<'\n';
    }
}