Cod sursa(job #1927121)
| Utilizator | Data | 14 martie 2017 22:27:39 | |
|---|---|---|---|
| Problema | Ridicare la putere in timp logaritmic | Scor | 10 |
| Compilator | cpp | Status | done |
| Runda | Arhiva educationala | Marime | 0.46 kb |
#include <cstdio>
#define M 1999999973
using namespace std;
long long a,b,sol=1;
void Read(){
freopen("lgput.in","r",stdin);
scanf("%lld%lld",&a,&b);
}
void Pow(){
long long i;
for (i=0;(1<<i)<=b;++i)
if (((1<<i)&b)>0) sol=(sol*a)%M;
else a=(a*a)%M;
}
void Write(){
freopen("lgput.out","w",stdout);
printf("%lld",sol);
}
int main()
{
Read();
Pow();
Write();
return 0;
}
