Cod sursa(job #2642731)

Utilizator luiz_felipeLuiz Felipe luiz_felipe Data 16 august 2020 23:59:03
Problema Suma divizorilor Scor 0
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.5 kb
#include <fstream>
using namespace std;
const int MOD = 1999999973;
ifstream f("sumadiv.in");
ofstream g("sumadiv.out");
int putere(int x, int y)
{
	int rez = 1;
	while (y)
	{
		if (y % 2) rez = (1LL * rez * x) % MOD;
		x = (1LL * x * x) % MOD;
		y /= 2;
	}
	return rez;
}
int main()
{
	int a, b, x,s=0;
	f >> a >> b;
	x = putere(a, b);
	for (int i = 1; i * i <= x; i++)
		if (!(x % i))
		{
			s += i;
			int j = x / i;
			if (i != j) s += j;
		}
	g << s % 9901;
	f.close(); g.close();
}