Cod sursa(job #793364)
| Utilizator | Data | 2 octombrie 2012 18:35:43 | |
|---|---|---|---|
| Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
| Compilator | cpp | Status | done |
| Runda | Arhiva educationala | Marime | 0.47 kb |
#include <cstdio>
#define mod 1999999973
using namespace std;
long long n;
long long p;
long long pow (long long p){
if (p == 1){
return n;
}
long long x = pow (p / 2);
x = x * x % mod;
if (p % 2 == 0){
return x;
}
return x * n % mod;
}
int main()
{
freopen ("lgput.in", "r", stdin);
freopen ("lgput.out", "w", stdout);
scanf ("%lld %lld", &n, &p);
printf ("%lld", pow(p));
return 0;
}
