Cod sursa(job #1922717)

Utilizator SirbuSirbu Ioan Sirbu Data 10 martie 2017 18:36:01
Problema Suma si numarul divizorilor Scor 10
Compilator cpp Status done
Runda Arhiva educationala Marime 0.84 kb
#include <fstream>
#define mod 9973
using namespace std;
ifstream fin ("ssnd.in");
ofstream fout ("ssnd.out");

/*
    Solutie de 70p folosind
    descompunere in factori primi
*/

int main (){

  int t;
  long long x;
  fin >> t;
  for (int i = 1; i <= t; ++i){
    fin >> x;
    int copie = x;
    int nr_div = 1;
    int suma_div = 1;
    for (int j = 2; j*j <= x; ++j){
      int factor = j;
      int exp = 0;
      while (copie % j == 0){
        factor = (factor * j)%mod;
        copie = copie/j;
        exp++;
      }
      factor = ((factor-1)/((j-1)%mod))%mod;
      suma_div *= factor;
      nr_div *= (exp+1);
    }
      if(copie > 1){
        nr_div = nr_div * 2;
        int plm = (copie*copie-1)%mod;
        suma_div *= (plm/(copie-1))%mod;
      }
    fout << nr_div << " " << suma_div << "\n";
  }

}