Cod sursa(job #800595)

Utilizator enedumitruene dumitru enedumitru Data 22 octombrie 2012 09:04:21
Problema Suma divizorilor Scor 30
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.64 kb
#include<fstream>
#define MOD 9901
 using namespace std;
 ifstream f("sumdiv.in");
 ofstream g("sumdiv.out");
 int a,b,k=0,d;
 int e[50],p[50];
 inline int calc(int a, int k)
{   int p=a;

while(--k) p*=a;

return p;
}

 int main()
 {  f>>a>>b;
    d=2;
    while(d*d<=a)
    {
        if(a%d==0)
        {
            e[++k]=0; p[k]=d;
            while(a%d==0)
            {
                e[k]++; a/=d;
            }

        }
        ++d;
    }
    if(a>1) {e[++k]=1; p[k]=a;}
    int s=1;
    for(int i=1; i<=k; ++i)
        s=(s*(calc(p[i],e[i]*b+1)-1)/(p[i]-1))%MOD;
    g<<s<<'\n'; g.close();
    return 0;
 }