Cod sursa(job #314972)

Utilizator brainwashed20Alexandru Gherghe brainwashed20 Data 13 mai 2009 21:16:25
Problema Ridicare la putere in timp logaritmic Scor 0
Compilator cpp Status done
Runda Arhiva educationala Marime 0.33 kb
#include <stdio.h>

#define C 1999999973

int main()
{
	freopen("modulo.in","r",stdin);
    freopen("modulo.out","w",stdout);

    long long a,b,p,sol=1;

    scanf("%lld %lld",&a,&b);
    p=a;

    while(b)
    {
		if(b%2) sol=(sol*p)%C;
		p=(p*p)%C;
		b/=2;
    }

    printf("%lld\n",sol);

    return 0;
}