Cod sursa(job #2302193)
Utilizator | Data | 13 decembrie 2018 22:06:18 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | c-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.25 kb |
#include<stdio.h>
long long y=1,x;
int N=1999999973,n,p;
int main()
{
freopen("lgput.in","r",stdin),freopen("lgput.out","w",stdout),scanf("%d%d",&n,&p);
for(x=n;p;p>>=1,x=(x*x)%N)
if(p&1)
y=(x*y)%N;
printf("%lld",y);
}