Cod sursa(job #2053855)
Utilizator | Data | 1 noiembrie 2017 14:30:41 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.36 kb |
#include <cstdio>
#define LL long long
const LL mod=1999999973;
LL a,b;
LL put(LL a,LL b)
{
if(b==0) return 1;
if(b==1) return a;
LL t=put(a,b/2);
return (((t*t)%mod)*put(a,b%2))%mod;
}
int main()
{
freopen ("lgput.in","r",stdin);
freopen ("lgput.out","w",stdout);
scanf("%lld%lld",&a,&b);
printf("%lld\n",put(a,b));
}