Cod sursa(job #1433623)
Utilizator | Data | 9 mai 2015 17:07:35 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.37 kb |
#include<fstream>
using namespace std;
ifstream cin("lgput.in");
ofstream cout("lgput.out");
#define mod 1999999973
#define LL long long
LL N, P;
LL pow(LL a, LL n)
{
if (!n) return 1;
if (n&1) return (pow(a,n-1)*a)%mod;
LL b = pow(a,n/2);
return (b*b)%mod;
}
int main()
{
cin >> N >> P;
cout << pow(N, P);
return 0;
}