Cod sursa(job #1456250)
| Utilizator | Data | 30 iunie 2015 10:59:39 | |
|---|---|---|---|
| Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
| Compilator | cpp | Status | done |
| Runda | Arhiva educationala | Marime | 0.49 kb |
#include <cstdio>
#include <algorithm>
#define Mod 1999999973
using namespace std;
long long n,p;
long long putere(long long a, long long b)
{
long long x;
if (b == 0)
return 1;
x = putere((a * a) % Mod, b / 2 );
if (b % 2)
x = (x * a) % Mod;
return x;
}
int main()
{
freopen("lgput.in", "r", stdin);
freopen("lgput.out", "w", stdout);
scanf("%lld %lld",&n, &p);
printf("%lld\n", putere(n, p));
return 0;
}
