快乐数: #include<iostream> using namespace std; bool is_Happy(int& a){ int temp=0; bool flag=0; while(a!=0){ if(a%10>1){ if(flag&&temp!=a%10){ return false; } else{ temp=a%10; flag=1; } } a=a/10; } return true; } int Least_Happy(int &N){ for(int i=1;i<100;i++){ int temp=i*N; if(is_Happy(temp))return i*N; } return -1; } int main(){ int N; while(true){ cin>>N; cout<<Least_Happy(N)<<endl; } return 0; }

相关推荐

一表renzha:手写数字识别就是一个作业而已
点赞 评论 收藏
分享
牛客网
牛客网在线编程
牛客网题解
牛客企业服务