Cod sursa(job #2163547)

Utilizator andreiutu111Noroc Andrei Mihail andreiutu111 Data 12 martie 2018 18:49:16
Problema Suma si numarul divizorilor Scor 0
Compilator cpp Status done
Runda Arhiva educationala Marime 0.76 kb
#include<bits/stdc++.h>
using namespace std;
ifstream f("ssnd.in");
ofstream g("ssnd.out");
int T,N,l,nr,s,v[100001];
bool viz[1000001];
void ciur(){
    for(int i=2;i<=1001;++i)
        if(!viz[i]){
            v[++l]=i;
            for(int j=2;i*j<=1000001;++j)
                    viz[i*j]=1;
        }
}
void descompfactpr(int x){
    int n=x,i=1;
    nr=s=1;
    while(v[i]*v[i]<=n){
        int p=0,y=x;
        while(x%v[i]==0)x/=v[i],++p;
        if(p>0){
            nr*=(p+1);
            (s*=(y/x*v[i]-1)/(v[i]-1))%9973;
        }
        ++i;
    }
    if(x>1)++nr,(s*=(x+1))%9973;
}
int main()
{
    f>>T;
    ciur();
    while(T--){
        f>>N;
        descompfactpr(N);
        g<<nr<<' '<<s<<'\n';
    }
    return 0;
}