Pagini recente » Cod sursa (job #1097534) | Cod sursa (job #3176167) | Cod sursa (job #537637) | Cod sursa (job #2798274) | Cod sursa (job #1526323)
#include <bits/stdc++.h>
using namespace std;
ifstream in("lgput.in");
ofstream out("lgput.out");
int timplogaritmic(int x,int n)
{
if(n<0) return timplogaritmic(1/x, -n);
else if(n == 0) return 1;
else if(n == 1) return x;
else if(n%2 == 0) return timplogaritmic(x*x , n/2);
else if(n%2 != 0) return timplogaritmic(x*x , (n-1)/2);
}
int main()
{
int n,x;
in>>x>>n;
out<<timplogaritmic(x,n);
return 0;
}