Cod sursa(job #1927131)
| Utilizator | Data | 14 martie 2017 22:31:20 | |
|---|---|---|---|
| Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
| Compilator | cpp | Status | done |
| Runda | Arhiva educationala | Marime | 0.47 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;
a=(a*a)%M;
}
}
void Write(){
freopen("lgput.out","w",stdout);
printf("%lld",sol);
}
int main()
{
Read();
Pow();
Write();
return 0;
}
