Cod sursa(job #2037963)

Utilizator stahlhelmVirtejaru Mihai stahlhelm Data 13 octombrie 2017 00:04:48
Problema Suma divizorilor Scor 20
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.44 kb
#include <iostream>
#include <fstream>
#include <math.h>
using namespace std;
ifstream f("sumdiv.in");
ofstream c("sumdiv.out");
int power(int A,int B)
{
    if(B==0)
        return 1;
    else return A*power(A,B-1);

}
int sumadiv(int A,int B)
{ int S=0,i,p;
p=power(A,B);
for(i=1;i<=p/2;i++)
  {
    if(p%i==0)
    S=S+i;
}
 return (S+p)%9901;
}

int main()
{
   int A,B;
    f>>A>>B;
   c<<sumadiv(A,B);
   return 0;

}