Cod sursa(job #2551326)
Utilizator | Data | 19 februarie 2020 19:13:07 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 10 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.25 kb |
#include<stdio.h>
#define mod 1999999973
int main(){
freopen("lgput.in","r",stdin);
freopen("lgput.out","w",stdout);
int n,p;
scanf("%d %d",&n,&p);
int r = 1;
int k = n;
while(p>0){
if(p%2==1) r=(r*k)%mod;
p/=2;
k=k*k;
}
printf("%d",r);
}