Cod sursa(job #1973087)

Utilizator sabinandreiBocan Sabin Andrei sabinandrei Data 24 aprilie 2017 13:43:14
Problema Suma divizorilor Scor 20
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.68 kb
#include <iostream>
#include <fstream>
#include <thread>
using namespace std;

ifstream fin("sumdiv.in");
ofstream fout("sumdiv.out");
int aqw[10000],ap=0;
int pow(int e, int b)
{
    int i,r=1;
    for(i=1;i<=b;i++)
    {
       r=r*e;
    }
    return r;
}
void div(int a)
{
    int i;
    ap=0;
    for(i=1;i<=a;i++)
    {
        if(a%i==0)
        {
            ap++;
            aqw[ap]=i;
        }
    }
}
int sum()
{
    int i,r=0;
    for(i=1;i<=ap;i++)
    {
        r=r+aqw[i];
    }
    return r;
}
int n,b;
long long int a,p,i,r;
int main()
{
    fin>>n>>b;
    p=pow(n,b);
    div(p);
    r=sum();
    fout<<r;
    return 0;
}