Cod sursa(job #571312)

Utilizator bocacristiBoca Nelu Cristian bocacristi Data 4 aprilie 2011 11:57:36
Problema Suma divizorilor Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.38 kb
#include <fstream>
#include <cstdio>
using namespace std;


long long n;

int sumdiv()
{
		long long s = 0; 
		for ( int i = 1; i*2 <= n; ++i )
				if ( n % i == 0 )
						s += i;
		return s;
}

int main()
{
		ifstream fin("sumdiv.in");
		freopen("sumdiv.out", "w", stdout);
		int a, b;
		fin >> a >> b;
		n = a;
		
		for ( ; b;--b)
				n *= a; 
		printf("%d\n", sumdiv());
		
		return 0;	
}