#include <stdio.h>
int exponent_fast(int x,int n)
{
int result=1,m,sample=x;
m=n;
while(m>0)
{
while( m%2 == 0)
{
sample =sample *sample;
m/=2;
if(m==0)break;
}
--m;
result = result * sample;
}
return result;
}
int main(void) {
// your code goes here
printf("%d\n",exponent_fast
(2,4)); printf("%d\n",exponent_fast
(2,3)); printf("%d\n",exponent_fast
(3,4)); printf("%d\n",exponent_fast
(3,3)); return 0;
}
I2luY2x1ZGUgPHN0ZGlvLmg+CgppbnQgZXhwb25lbnRfZmFzdChpbnQgeCxpbnQgbikKewoJaW50IHJlc3VsdD0xLG0sc2FtcGxlPXg7CgltPW47Cgl3aGlsZShtPjApCgl7CgkJd2hpbGUoIG0lMiA9PSAwKQoJCXsKCQkJc2FtcGxlID1zYW1wbGUgKnNhbXBsZTsKCQkJbS89MjsKCQkJaWYobT09MClicmVhazsKCQl9CgkJLS1tOwoJCXJlc3VsdCA9IHJlc3VsdCAqIHNhbXBsZTsKCX0KCXJldHVybiByZXN1bHQ7Cn0KaW50IG1haW4odm9pZCkgewoJLy8geW91ciBjb2RlIGdvZXMgaGVyZQoJcHJpbnRmKCIlZFxuIixleHBvbmVudF9mYXN0KDIsNCkpOwoJcHJpbnRmKCIlZFxuIixleHBvbmVudF9mYXN0KDIsMykpOwoJcHJpbnRmKCIlZFxuIixleHBvbmVudF9mYXN0KDMsNCkpOwoJcHJpbnRmKCIlZFxuIixleHBvbmVudF9mYXN0KDMsMykpOwoJcmV0dXJuIDA7Cn0K