问题描述:
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...
During the past 30 years there has been a resurgence of interest in the classical orbital boundary value problem of Lambert, largely because of its relevance to space rendezvous and interception....
2.3.1 General Spectrum Problem 30 2.3.2 Linear Modulation Spectra 31 2.3.3 Spectral and Power Out-of-Band Plots 32 2.4 Transmission Impairments 35 2.4.1 Intersymbol Interference 35 2.4.2 Eye Patterns ...
0-1-knapsack-problem-master (30).zip
0-1-knapsack-problem-master (30)c.zip
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...
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.
4 edition (April 30, 2013) Language: English ISBN-10: 1285096266 ISBN-13: 978-1285096261 Only Doyle's C# PROGRAMMING: FROM PROBLEM ANALYSIS TO PROGRAM DESIGN, 4E brilliantly balances today's ...
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种状态,,详见博客文章
problem solving technique
addImageKind( 24 , 30 , 246 ); // add image { w = 24 ; h = 30 ; demand = 246 }pk . addImageKind( 13 , 56 , 562 ); // add image { w = 13 ; h = 56 ; demand = 562 }pk . addImageKind( 14 , 22 , 1000 ); /...
txt文件为1985年美赛MCM题目,是A题。 内容是英文的,30行左右。非常好的学习资料,想做A题的可以看看。 希望大家美赛顺利~
The Portland Problem Behavior Checklist THE PORTLAND PROBLEM BEHAVIOR CHECKLIST STEVEN A. WAKSMAN ROBERT J.... Portland, Oregon Oregon Ciry....It is estimated that between 10 and 30%
自从20世纪30年代以来,图灵机、计算这些重要的概念在科学的天空中就一直闪烁着无限的光彩。尤其是近年来量子计算机、生物计算机、DNA计算等领域的创新工作引起了世人的广泛关注。我们不禁问这样的问题,国外究竟为...
Delphi VCLSkin 5.30 ... VCLSkin is a component to create skinnable user interface for Delphi/C++Builder application, It is easy to use, just put one component on mainform, ...* fix caption paint problem...