hdu 2035 反复平方法

2015-07-20 17:05:27 · 作者: · 浏览: 22
#include 
  
   
#include 
   
     #include 
    
      using namespace std; int fun(int a,int b){ //int c = 0; int d = 1; stack
     
       st; while(b){ st.push(b & 1); b >>= 1l; } while(!st.empty()){ int t = st.top(); st.pop(); //c <<= 1; d = d*d %1000; if(t == 1){ // c ++; d = (d*a)%1000; } } return d; } int main(){ int a,b; while(cin >> a >> b,a||b){ cout << fun(a,b) << endl; } return 0; }
     
    
   
  

?