Cod sursa(job #362019)
| Utilizator | Data | 7 noiembrie 2009 17:10:08 | |
|---|---|---|---|
| Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
| Compilator | cpp | Status | done |
| Runda | Arhiva educationala | Marime | 0.37 kb |
#include <stdio.h>
#define mod 1999999973
long long put(long a,long b)
{
if(b==1) return a%mod;
if(b%2) return (a*put(a,b-1))%mod;
else
{ long long x=put(a,b/2);
return (x*x)%mod;
}
}
int main()
{
long n,p;
freopen("lgput.in","r",stdin);
freopen("lgput.out","w",stdout);
scanf("%ld %ld",&n,&p);
printf("%lld",put(n,p)%mod);
return 0;
}
