Advertisement
karbaev

QuickPowSimple

Nov 30th, 2014
175
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.29 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7.     double a;
  8.     int n;
  9.     cin>>a>>n;
  10.  
  11.     double x = 1;
  12.     while(n){
  13.               if(n%2==1)
  14.               {
  15.                    x *=a;
  16.               }
  17.               n/=2;
  18.               a*=a;
  19.     }
  20.     cout<<x;
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement