#include<iostream>
using namespace std;
bool selfNum[10000];
bool findNoneSelfNum(int index){
int one,ten,hundred,thousand;
if(index>=10000){
return false;
}
if(selfNum[index]==false){
return true;
}
thousand=index/1000;
hundred=(index-thousand*1000)/100;
ten=(index-thousand*1000-hundred*100)/10;
one=index-thousand*1000-hundred*100-ten*10;
int noneSelfNum=index+thousand+hundred+ten+one;
if(noneSelfNum<10000){
findNoneSelfNum(noneSelfNum);
selfNum[noneSelfNum]=false;
}else{
return false;
}
}
int main(int argc, char *argv[]){
for(int i=1;i<10000;i++){
selfNum[i]=true;
}
for(int i=1;i<10000;i++){
findNoneSelfNum(i);
}
for(int i=1;i<10000;i++){
if(selfNum[i]){
cout<<i<<endl;
}
}
return 0;
}
POJ-1316
最新推荐文章于 2019-06-29 14:22:49 发布