Cod sursa(job #2003014)
| Utilizator | Data | 21 iulie 2017 14:59:19 | |
|---|---|---|---|
| Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
| Compilator | cpp | Status | done |
| Runda | Arhiva educationala | Marime | 0.39 kb |
#include <cstdio>
using namespace std;
const int modulo = 1999999973;
int main()
{
freopen("lgput.in","r",stdin);
freopen("lgput.out","w",stdout);
long long n,p;
long long rez = 1;
scanf("%lld %lld",&n,&p);
while(p != 0)
{
if(p % 2 == 1)
rez = (rez*n) % modulo;
n = (n*n) % modulo;
p /= 2;
}
printf("%lld",rez);
return 0;
}
