设计一个程序,求出712的729次方的最后4位数是多少?
\#include "stdafx.h"\
/\*\
设计一个程序,求出712的729次方的最后4位数是多少?\
\*/\
int PowerLow4( int num, int pow ){\
if( pow == 1 ) return num;\
\
int ret = PowerLow4( num, pow/2 )%10000;\
\
if( pow%2 == 0 )\
return ret\*ret%10000;\
else{\
// Each time you do multiplication, you should ensure it won't overflow.\
return ret\*ret%10000\*num%10000;\
}\
}\
int main(){\
\
cout \<\< setw(4) \<\< std::setfill('0') \<\< PowerLow4( 712 , 729 ) \<\< endl;\
}