Cod sursa(job #1939695)
| Utilizator | Data | 25 martie 2017 22:38:00 | |
|---|---|---|---|
| Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
| Compilator | cpp | Status | done |
| Runda | Arhiva educationala | Marime | 0.45 kb |
#include <iostream>
#include<stdio.h>
#define modulo 1999999973
using namespace std;
long long n, p, rez, nlaputere;
int main()
{
freopen("lgput.in","r",stdin);
freopen("lgput.out","w",stdout);
scanf("%ld %ld",&n,&p);
nlaputere=n;
rez=1;
while(p){
if (p&1)
rez=(rez*nlaputere)%modulo;
p/=2;
nlaputere=(nlaputere*nlaputere)%modulo;
}
printf("%lld",rez);
return 0;
}
