Cod sursa(job #2157991)

Utilizator AndreiBadescuBadescu Andrei-Octavian AndreiBadescu Data 10 martie 2018 08:42:58
Problema Suma si numarul divizorilor Scor 50
Compilator cpp Status done
Runda Arhiva educationala Marime 0.93 kb
#include <fstream>

typedef unsigned int uint;
using namespace std;

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

const uint MOD = 9973;
uint n, x, nr, s;

inline void Div ( uint x, uint &nr, uint &s )
{
	int t, p, d = 3;

	nr = s = 1;

	if ( x % 2 == 0 )
	{
		p = 1, t = 2;

		while ( x % 2 == 0 )
			x /= 2, t <<= 1, ++p;

		nr *= p, nr %= MOD;
		s *= (t - 1), s %= MOD;
	}

	while ( x > 1 && d * d <= x )
	{
		if ( x % d == 0 )
		{
			p = 1, t = d;

			while ( x % d == 0 )
				x /= d, t *= d, ++p;

            nr *= p, nr %= MOD;
            s *= (t - 1) / (d - 1), s %= MOD;
		}

		d += 2;
	}

	if ( x > 1 )
    {
        nr <<= 1, s *= (x * x - 1) / (x - 1);
        nr %= MOD, s %= MOD;
    }
}

int main()
{
	ios::sync_with_stdio (false);

	int i;

	fin >> n;

	for ( i = 0; i < n; ++i )
	{
		fin >> x;

		Div (x, nr, s);

		fout << nr << " " << s << '\n';
	}
}