您的位置:首页 > 其它

算法提高 ADV-185 五次方数

2017-09-17 09:09 204 查看
问题描述

  对一个数十进制表示时的每一位数字乘五次方再求和,会得到一个数的五次方数

  例如:1024的五次方数为1+0+32+1024=1057

  有这样一些神奇的数,它的五次方数就是它自己,而且这样的数竟然只有有限多个

  从小到大输出所有这样的数

输出格式

  每个数独立一行输出

样例输出

     10
     200
     3000

public class Main{
public static void main(String[] args) {
int ge;
int shi;
int bai;
int qian;
int wan;
int shiwan;
int temp;
for(int i=10; i<200000; i++){
ge = i%10;
temp = i/10;
shi = temp%10;
temp = temp/10;
bai = temp%10;
temp = temp/10;
qian = temp%10;
temp = temp/10;
wan = temp%10;
temp = temp/10;
shiwan = temp;
if((int)Math.pow(ge, 5)>i){
ge = 0;
shi = 0;
bai = 0;
qian = 0;
wan = 0;
shiwan = 0;
continue;
}else if((int)Math.pow(shi, 5)>i){
continue;
}else if((int)Math.pow(bai, 5)>i){
continue;
}else if((int)Math.pow(qian, 5)>i){
continue;
}else if((int)Math.pow(wan, 5)>i){

continue;
}else if((int)Math.pow(shiwan, 5)>i){
continue;
}else if(((int)Math.pow(ge, 5)+(int)Math.pow(shi, 5)+(int)Math.pow(bai, 5)+(int)+Math.pow(qian, 5)+(int)Math.pow(wan, 5)+(int)Math.pow(shiwan, 5))==i){
//				System.out.println(ge+" "+shi+" "+bai+" "+qian+" "+wan+" "+shiwan);
System.out.println(i);
}

}
}
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: