Last active
August 29, 2015 14:06
-
-
Save haroldxin/64aeb77b6588cbed0f45 to your computer and use it in GitHub Desktop.
QUICKLY MI
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <stdio.h> | |
using namespace std; | |
typedef unsigned int uint; | |
void pow(uint x,uint y){ | |
uint pow; | |
if(x == 1) | |
cout << 1; | |
if(x != 0 && y == 0) | |
cout << 1; | |
if(x == 0 && y == 0) | |
throw "invalid argument"; | |
pow=1; | |
while (y>0){ | |
if(y%2==1)pow=pow*x; | |
x=x*x; | |
y=y/2; | |
} | |
cout << pow; | |
} | |
int main (){ | |
int a,b; | |
cin >> a; | |
cin >> b; | |
pow(a,b); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment