Cod sursa(job #1671852)
| Utilizator | Data | 2 aprilie 2016 11:11:26 | |
|---|---|---|---|
| Problema | Ridicare la putere in timp logaritmic | Scor | 10 |
| Compilator | cpp | Status | done |
| Runda | Arhiva educationala | Marime | 0.49 kb |
#include <iostream>
#include <fstream>
#define x 1999999973
using namespace std;
ifstream in("lgput.in");
ofstream out("lgput.out");
long long n, a;
long long power(long long n, long long a)
{
if(a == 0)
{
return 1LL;
}
if(a % 2 == 0)
{
return power(n * n, a / 2);
}
if(a % 2 == 1)
{
return power(n * n, a / 2) * n;
}
}
int main()
{
in >> n >> a;
out << power(n,a) % x;
return 0;
}
