Cod sursa(job #3324926)

Utilizator tudor13mai@gmail.comBuciuman Tudor [email protected] Data 24 noiembrie 2025 10:02:34
Problema Suma si numarul divizorilor Scor 10
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 1.07 kb
#include <bits/stdc++.h>
using namespace std;
ifstream fin("ssnd.in");
ofstream fout("ssnd.out");
const long long Mod=9973;
#define l long long
vector<int> v;
int w[1000100];
//int d[1000100];
int n,m,s;
int num=0;
long long M;
void Calc(l x){
    int a=1,d=0;
    l b=1;
    while(v[d]<=x){
        int p=v[d],k=1;
        if(x%v[d]==0){
        while(x%v[d]==0){
            p*=v[d];
            k++;
            x=1ll*x/v[d];
        }
        a*=(k);
        b=1ll*b*(p-1)/(v[d]-1);
        }
        d++;
    }
    if(x>1){
        a*=2;
        b*=(x*x-1);
        b/=(x-1);
    }
    fout<<a<<' '<<b<<'\n';
}
void Eratos(){
    for(int i=2; i<=1000; i++){
        for(int j=2; i*j<=1000000; j++){
            w[i*j]=1;
        }
    }
    for(int i=2; i<=1000000; i++){
        if(!w[i])
            v.push_back(i);
    }
}
int main(){
    l a,b;
    ios::sync_with_stdio(false);
    fin.tie(0);
    fout.tie(0);
    Eratos();
    fin>>n;
    for(int i=1; i<=n; i++){
        fin>>a;
        Calc(a);
    }

    return 0;
}