http://acm.hdu.edu.cn/showproblem.php?pid=1128
题意为找出从1开始的所有自私数,自私数满足,对于所有数据本身加上各个数位上和不会等于的数,就称为自私数
#include<iostream>
#include<cstring>
#include<cmath>
using namespace std ;
#define MAX 1000005
int num[ MAX ] ;
int judge( int n )
{
int sum = n ;
while( n )
{
sum += n % 10 ;
n /= 10 ;
}
num[ sum ] = 1 ;
}
int main()
{
int n ;
memset( num , 0 , sizeof( num ) ) ;
for( int i = 1 ; i < MAX; ++i )
{
if( !num[ i ] )
cout << i << endl ;
judge( i ) ;
}
}