Cod sursa(job #1416608)
| Utilizator | Data | 8 aprilie 2015 15:26:44 | |
|---|---|---|---|
| Problema | Ridicare la putere in timp logaritmic | Scor | 10 |
| Compilator | cpp | Status | done |
| Runda | Arhiva educationala | Marime | 0.44 kb |
#include <fstream>
#define rest 1999999973
#define ll long long int
using namespace std;
ifstream fin("lgput.in");
ofstream fout("lgput.out");
ll pow(ll x, ll n)
{
if(n == 0) return 1;
else if(n == 1) return x;
else if(n%2 != 0) return x * pow(x*x, (n-1)/2);
else return pow(x*x, n/2);
}
int main()
{
ll x, n;
ll rez;
fin >> x >> n;
rez = pow(x,n);
fout << rez%rest;
return 0;
}
