Cod sursa(job #1871520)
Utilizator | Data | 7 februarie 2017 14:35:35 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.42 kb |
#include <stdio.h>
#define mod 1999999973
using namespace std;
long long int n, p, sol;
int main()
{
freopen("lgput.in", "r", stdin);
freopen("lgput.out", "w", stdout);
scanf("%lld %lld", &n, &p);
sol = 1;
while (p > 0) {
if (p % 2 == 1) sol = (1LL * sol * n) % mod;
n = (1LL * n * n) % mod; p = p / 2;
}
printf("%lld", sol);
return 0;
}