Faith


私信TA

用户名:1310510120

访问量:39719

签 名:

求介绍工作

等  级
排  名 229
经  验 6066
参赛次数 1
文章发表 54
年  龄 0
在职情况 学生
学  校 武汉生物工程学院
专  业

  自我简介:


解题思路:算过9的5次方为59049,计算6位数全是9,加起来不超过360000,所以,只用判断1000000之前就行






注意事项:0和1不能考虑进去,这是个坑!





参考代码:

public class 五次方数 {

	public static void main(String[] args) {
	for(int a=0;a<10;a++)
	for(int b=0;b<10;b++)
	for(int c=0;c<10;c++)
	for(int d=0;d<10;d++)
	for(int e=0;e<10;e++)
	for(int f=0;f<10;f++){
	int num=(int) (Math.pow(a, 5)+Math.pow(b, 5)+Math.pow(c, 5)+Math.pow(d, 5)+Math.pow(e, 5)+Math.pow(f, 5));
	if(num==(a*100000+b*10000+c*1000+d*100+e*10+f)&&num!=0&&num!=1)
	System.out.println(num);	
	}
	}
}


 

0.0分

3 人评分

看不懂代码?想转换其他语言的代码? 或者想问其他问题? 试试问问AI编程助手,随时响应你的问题:

编程语言转换万能编程问答  

代码解释器

代码纠错

SQL生成与解释

  评论区