生成元(JAVA语言)

package 第三章;


import java.util.Scanner;


public class 生成元 {


public static void main(String[] args) {
// TODO Auto-generated method stub
final int max=100005;
int a[]=new int[max];
for(int i=1;i<max;i++) {
int x=i,y=i;
while(x>0) {
y+=x%10;
x/=10;
}

if(y<max&&(a[y]>i||a[y]==0)) {
a[y]=i;
}
}
int n;
Scanner in=new Scanner(System.in);
n=in.nextInt();
System.out.println(a[n]);
}


}
全部评论

相关推荐

不愿透露姓名的神秘牛友
07-08 13:05
点赞 评论 收藏
分享
牛客84809583...:举报了
点赞 评论 收藏
分享
不愿透露姓名的神秘牛友
07-08 14:08
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务