问题描述:
Surprisingly there are only three numbers that can be written as the sum of fourth powers of their digits:
1634 = 14 + 64 + 34 + 44
8208 = 84 + 24 + 04 + 84
9474 = 94 + 44 + 74 + 44
As 1 = 14 is not a sum it is not included.
The sum of these numbers is 1634 + 8208 + 9474 = 19316.
Find the sum of all the numbers that can be written as the sum of fifth powers of their digits.
解决问题:
水仙花数。
遍历计算。
public static int find(int number){
int sum =0;
int i;
//pow(9,5)*6
double UP = Math.pow(9, 5)*6;
for( i=4; i<=UP;i++){
int cur =i;
String s = i+"";
int[] num = new int[s.length()];
int index = 0;
while(cur!=0){
num[index] = cur%10;
cur = cur/10;
index++;
}
int result = 0;
for(int j=0; j<num.length; j++){
result += num[j]*num[j]*num[j]*num[j]*num[j];
// System.out.print(num[j]+"_");
}
if(result==i){
System.out.println(i);
sum+=i;
}
}
return sum;
}
分享到:
相关推荐
21.9 Charging related problem 30 21.10 FTP related problem 30 21.11 Command restrict problem 31 22. IOG related problem 31 22.1 Common part 31 22.2 NODE BLOCKED 33 22.3 STS Related Problems 33 22.4 ...
Computer Networking: A Top-Down Approach, 6th Edition Solutions to Review Questions and Problems Version Date: May 2012 ...This document contains the solutions to review questions ...Problem 1 There...
Publication Date: 2015-05-30 ISBN-10: 9814663735 ISBN-13: 9789814663731 The author looks at the issues of how computing are used and taught, with a focus on embedding computers within problem solving...
29. 问题,苦恼 n - problem 30. 〔用手或器具〕击;打 v - hit 31. 立即;马上 - immediately 32. 陷入;参与 - get involved 33. 她自己 pron - herself 34. 绷带 n 用绷带包扎 v - bandage 35. 生病的;有病的 ...
29. 问题,苦恼 n - problem 30. (用手或器具)击;打 v - hit 31. 立即;马上 - immediately 32. 陷入;参与 - get involved 33. 她自己 pron - herself 34. 绷带 n 用绷带包扎 v - bandage 35. 生病的;有病的 ...
苦恼 - problem 30. (用手或器具) 击;打 - hit 31. 立即;马上 - immediately 32. 陷入;参与 - get involved 33. 她自己 - herself 34. 绷带/ 用绷带包扎 - bandage 35. 生病的;有病的 - sick 36. 膝;膝盖 - ...
by the standard IEEE benchmark systems with 14, 30, 57, 118, and 300 buses as well as several randomly generated systems. Since this condition is hard to study, a sufficient zero-duality-gap condition...
此外,从部分内容中可见,研究者Eugeniusz Nowicki和Czeslaw Smutnicki发表的研究成果,在解决特定规模的Job Shop问题方面取得了显著的成效,并在30秒内解决了10x10的标准测试问题。这表明他们的快速禁忌搜索算法...
戴尔PowerEdge T30服务器作为面向小型企业及家庭办公室设计的入门级塔式服务器,以其卓越的计算能力、稳定的运行表现和丰富的存储选项深受用户青睐。而BIOS作为服务器硬件和操作系统沟通的桥梁,其稳定性和兼容性对...
dragons are small, roughly 10 kg, and after a year grow to roughly 30 40 kg. They continue to grow throughout their life depending on the conditions and amount of food available to them.
这是T30没屏蔽m2接口的最后一个bios版本,此版本之后主板m2接口被戴尔官方屏蔽。
C#,子集和问题(Subset Sum Problem)的算法与源代码 1 子集和问题(Subset Sum Problem) 给定一组非负整数和一个值和,确定给定集合中是否存在和等于给定和的子集。 示例: 输入:set[]={3,34,4,12,5,2},...
1291 pages (December 30, 2016) 出版社: Prentice Hall; 3 edition Language: English ISBN-10: 0131474340 ISBN-13: 9780131474345 Contents Preface. 0. Computers, Objects, and Java. 1. Java Program Design...
C#,蛇梯问题(Snake and Ladder Problem)的算法与源代码 蛇梯问题 Snake and Ladder Problem 给定一个蛇梯板,找出从源单元格或第一个单元格到达目标单元格或最后一个单元格所需的最小掷骰次数。基本上,玩家可以...
GCJ 资格赛 Problem A 30分solution 思路很水,,直接判断10种状态,,详见博客文章
针对2006年MCM Problem A中的问题,我们需要配置这种“手动”灌溉系统,以最小化灌溉80米乘30米的田地所需的时间。任务要求找到一种算法来确定如何灌溉矩形田地,以便牧场主维护灌溉系统所花费的时间最少。田地中...
### Ulam's Problem:在没有反馈的情况下搜索与说谎者博弈 #### 一、问题背景与定义 Ulam的问题起源于斯坦尼斯拉夫·乌拉姆(Stanislaw Ulam)提出的一个智力游戏,该问题涉及到如何在面对可能的谎言回答时确定一...
gnome-shell-3.28.3-30.el7.x86_64.rpm