Cod sursa(job #3378095)

Utilizator daviddxmqStan David Andrei daviddxmq Data 25 noiembrie 2026 11:41:04
Problema Suma si numarul divizorilor Scor 70
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 1.06 kb
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>

using namespace std;

const int MOD = 9973;

int t;
long long n, card, sum;
vector<pair <int, int> > putPrim;

void factPrim(long long x) {
    for (int i = 2; i <= x; ++i) {
        if (x % i == 0) {
            int putere = 0;
            while (x % i == 0) {
                x /= i;
                ++putere;
            }
            putPrim.push_back({i, putere});
        }
    }
}

void calcDiv(long long x) {
    factPrim(x);
    for (auto& pereche : putPrim) {
        card *= (pereche.second + 1);
        sum = (sum * (((long long)pow(pereche.first, pereche.second + 1) - 1) / (pereche.first - 1)) % MOD) % MOD;
    }
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    freopen("ssnd.in", "r", stdin);
    freopen("ssnd.out", "w", stdout);

    cin >> t;
    while (t--) {
        cin >> n;
        card = 1, sum = 1;
        putPrim.clear();
        calcDiv(n);
        cout << card << " " << sum << "\n";
    }
    return 0;
}