Pagini recente » Cod sursa (job #2288611) | Cod sursa (job #1100978) | Cod sursa (job #3229808) | Cod sursa (job #2577827) | 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;
}