a040.
阿姆斯壯數
| From: [61.62.169.115] |
發表日期
:
2015-03-21 22:32
#include<iostream>
#include<cstdlib>
#include<cmath>
using namespace std ;
int main()
{
int start , end , test , num , n , flag ;
while(cin >> start >> end )
{
flag = 0 ;
test = start ;
for( n = 0 ; test ; n++ )
{
test /= 10 ;
}
for( ; start < end ; start++ )
{
num = 0 ;
test = start ;
while( test )
{
num += (int)pow( test%10 , n );
test /= 10 ;
}
if( num == start )
{
cout << num << " " ;
flag = 1 ;
}
}
if( !flag )
cout << "none" ;
cout << endl ;
}
return 0 ;
}