Cod sursa(job #1348874)
Utilizator | Data | 19 februarie 2015 21:31:11 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 10 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.38 kb |
#include <stdio.h>
using namespace std;
int putere (int a, int b){
int p=1;
while(b!=0){
if(b%2==1){
p=(p*a)%1999999973;
}
a=(a*a)%1999999973;
b=b/2;
}
return p;
}
int main()
{
int m,n;
freopen("lgput.in", "r", stdin);
freopen("lgput.out", "w", stdout);
scanf("%d %d", &m, &n);
printf("%d", putere(m,n));
return 0;
}