Cod sursa(job #3294357)
| Utilizator | Data | 21 aprilie 2025 23:02:44 | |
|---|---|---|---|
| Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
| Compilator | c-64 | Status | done |
| Runda | Arhiva educationala | Marime | 0.39 kb |
#include <stdio.h>
long long putere(long long A, long long n)
{
long long P = 1;
n %= 1999999973;
while(n)
{
if(n%2 == 1)
P = (P*A)%1999999973;
A = (A*A)%1999999973;
n = (n/2)%1999999973;
}
return P;
}
int main()
{
freopen("lgput.in", "r", stdin);
freopen("lgput.out", "w", stdout);
long long n, p;
scanf("%lld%lld", &n, &p);
long long put = putere(n, p);
printf("%lld", put);
}