Cod sursa(job #1946299)

Utilizator AkrielAkriel Akriel Data 30 martie 2017 02:54:37
Problema Suma si numarul divizorilor Scor 100
Compilator cpp Status done
Runda Arhiva educationala Marime 4.22 kb
#include <bits/stdc++.h>

/**

                                          `-.`'.-'
                                       `-.        .-'.
                                    `-.    -./\.-    .-'
                                        -.  /_|\  .-
                                    `-.   `/____\'   .-'.
                                 `-.    -./.-""-.\.-      '
                                    `-.  /< (()) >\  .-'
                                  -   .`/__`-..-'__\'   .-
                                ,...`-./___|____|___\.-'.,.
                                   ,-'   ,` . . ',   `-,
                                ,-'   ________________  `-,
                                   ,'/____|_____|_____\
                                  / /__|_____|_____|___\
                                 / /|_____|_____|_____|_\
                                ' /____|_____|_____|_____\
                              .' /__|_____|_____|_____|___\
                             ,' /|_____|_____|_____|_____|_\
,,---''--...___...--'''--.. /../____|_____|_____|_____|_____\ ..--```--...___...--``---,,
                           '../__|_____|_____|_____|_____|___\
      \    )              '.:/|_____|_____|_____|_____|_____|_\               (    /
      )\  / )           ,':./____|_____|_____|_____|_____|_____\             ( \  /(
     / / ( (           /:../__|_____|_____|_____|_____|_____|___\             ) ) \ \
    | |   \ \         /.../|_____|_____|_____|_____|_____|_____|_\           / /   | |
 .-.\ \    \ \       '..:/____|_____|_____|_____|_____|_____|_____\         / /    / /.-.
(=  )\ `._.' |       \:./ _  _ ___  ____  ____ _    _ _ _ _ _  _ __\        | `._.' /(  =)
 \ (_)       )        \/                                            \       (       (_) /
  \    `----'          """"""""""""""""""""""""""""""""""""""""""""""        `----'    /
   \   ____\__                                                              __/____   /
    \ (=\     \                                                            /     /-) /
     \_)_\     \                                                          /     /_(_/
          \     \                                                        /     /
           )     )  _                                                _  (     (
          (     (,-' `-..__                                    __..-' `-,)     )
           \_.-''          ``-..____                  ____..-''          ``-._/
            `-._                    ``--...____...--''                    _.-'
                `-.._                                                _..-'
                     `-..__               AKRIEL               __..-'
                           ``-..____                  ____..-''
                                    ``--...____...--''

*/

using namespace std;

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

const int N = 1e6+1;
const int modulo = 9973;

bitset <N> prime;

vector <int> primeNumbers;

long long int totalTests, number, contor, sum, coefficient, totalSum, totalContor;

void ciur(){
    prime.set();
    for ( int index = 2; index < N; index++ ){
        if ( prime[index] == true ){
            primeNumbers.push_back(index);
            for ( int multiple = index; multiple < N; multiple += index )
                prime[multiple] = false;
        }
    }
}

int main(){
    ciur();
    fin >> totalTests;
    for ( ; totalTests; totalTests-- ){
        fin >> number;
        totalContor = totalSum = 1;
        for ( auto it : primeNumbers ){
            if ( it*it > number )
                break;
            if ( number % it )
                continue;

            coefficient = it;
            sum = contor = 1;
            for ( ; number % it == 0; ){
                contor++;
                sum += coefficient;
                number /= it;
                coefficient = (coefficient*it)%modulo;
            }
            totalSum = (1LL*sum*totalSum)%modulo;
            totalContor *= contor;
        }

        if ( number > 1 ){
            sum = number%modulo + 1;
            totalContor *= 2;
            totalSum = (totalSum*sum) % modulo;
        }

        fout << totalContor << " " << totalSum << "\n";
    }
}