Cod sursa(job #1183749)

Utilizator xtreme77Patrick Sava xtreme77 Data 10 mai 2014 01:25:13
Problema Suma divizorilor Scor 100
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.97 kb
#include <cstdio>
#include <cmath>
#define op %9901
using namespace std;
int pow(int x,int y);
int main()
{
    int fact,a,b;
    freopen("sumdiv.in","r",stdin);
    freopen("sumdiv.out","w",stdout);
    scanf("%d%d",&a,&b);
    int suma=1;
    for(int j=2;1LL*j*j<=a;++j){
        if(a%j)continue;
        int fact=0;
        while(a%j==0){
            fact+=b;
            a/=j;
        }
        int p1=(pow(j,fact+1)-1 + 9901)op;
        int p2=pow(j-1,9899)op;
        suma=(((1LL*suma*p1)op)*p2)op;;
    }
    if(a>1){
        if(a op!=1){
            int p1 =(pow(a,b+1)-1+9901)op;
            int p2 =(pow(a-1,9899))op;
            suma=(((1LL*suma*p1)op)*p2)op;
        }
        else
            suma=(1LL*suma*(b+1))op;
    }
    printf("%d\n",suma op);
    return 0;
}
int pow(int x,int y){
    int rez;
    for(rez=1;y;y>>=1){
        if(y&1){
            rez=(1LL*rez*x)op;
        }
        x=(1LL*x*x)op;
    }
    return rez op;
}