`
to_zoe_yang
  • 浏览: 142373 次
  • 性别: Icon_minigender_2
  • 来自: 01
社区版块
存档分类
最新评论

Problem 30

 
阅读更多

问题描述:

 

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;
	}
	

 

分享到:
评论

相关推荐

    爱立信CSR数据采集规范

    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...

    Computer-Based.Problem.Solving.Process

    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...

    人教版八下英语单词表默写专用.doc

    29. 问题,苦恼 n - problem 30. 〔用手或器具〕击;打 v - hit 31. 立即;马上 - immediately 32. 陷入;参与 - get involved 33. 她自己 pron - herself 34. 绷带 n 用绷带包扎 v - bandage 35. 生病的;有病的 ...

    2014年春八年级英语下册《Unit1 What’t the matter》单词默写(无答案) (新版)人教新目标版.doc

    29. 问题,苦恼 n - problem 30. (用手或器具)击;打 v - hit 31. 立即;马上 - immediately 32. 陷入;参与 - get involved 33. 她自己 pron - herself 34. 绷带 n 用绷带包扎 v - bandage 35. 生病的;有病的 ...

    人教版八年级下册英语单词默写版.pdf

    苦恼 - problem 30. (用手或器具) 击;打 - hit 31. 立即;马上 - immediately 32. 陷入;参与 - get involved 33. 她自己 - herself 34. 绷带/ 用绷带包扎 - bandage 35. 生病的;有病的 - sick 36. 膝;膝盖 - ...

    Zero Duality Gap in Optimal Power Flow Problem

    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...

    PowerEdge_T30_1.0.2.zip

    标题“PowerEdge_T30_1.0.2.zip”所指的是一款针对戴尔PowerEdge T30服务器的BIOS更新程序。戴尔PowerEdge T30是一款面向小型企业和家庭办公室的入门级塔式服务器,它提供了强大的计算能力,支持多种存储选项,包括M...

    A Fast Taboo Search Algorithm for the Job Shop Problem

    此外,从部分内容中可见,研究者Eugeniusz Nowicki和Czeslaw Smutnicki发表的研究成果,在解决特定规模的Job Shop问题方面取得了显著的成效,并在30秒内解决了10x10的标准测试问题。这表明他们的快速禁忌搜索算法...

    0-1-knapsack-problem-master (30)c.zip

    此问题通常用动态规划来解决,而这里的"master (30)c.zip"和"0-1-knapsack-problem-master (29)c.zip"两个压缩包文件,很可能包含了C语言实现的0-1背包问题的源代码。 0-1背包问题的基本描述如下: 设有n件物品,...

    0-1-knapsack-problem-master (30).zip

    在这个压缩包文件"0-1-knapsack-problem-master (30).zip"中,我们可以推测包含了一个关于0-1背包问题的代码实现,可能是用C语言编写的。虽然这里没有提供具体的代码内容,但我将详细介绍0-1背包问题的基本概念、...

    2019_MCM_Problem_A.pdf

    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.

    dell 戴尔 PowerEdge T30 bios v1.0.2

    这是T30没屏蔽m2接口的最后一个bios版本,此版本之后主板m2接口被戴尔官方屏蔽。

    C#,子集和问题(Subset Sum Problem)的算法与源代码

    C#,子集和问题(Subset Sum Problem)的算法与源代码 1 子集和问题(Subset Sum Problem) 给定一组非负整数和一个值和,确定给定集合中是否存在和等于给定和的子集。 示例: 输入:set[]={3,34,4,12,5,2},...

    Java, Java, Java, Object-Oriented Problem Solving (3rd Edition 2016)

    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)的算法与源代码

    C#,蛇梯问题(Snake and Ladder Problem)的算法与源代码 蛇梯问题 Snake and Ladder Problem 给定一个蛇梯板,找出从源单元格或第一个单元格到达目标单元格或最后一个单元格所需的最小掷骰次数。基本上,玩家可以...

    GCJ2013_Problem_A_Tic-Tac-Toe-Tomke

    GCJ 资格赛 Problem A 30分solution 思路很水,,直接判断10种状态,,详见博客文章

    2006-2020 MCM Problem A.docx

    针对2006年MCM Problem A中的问题,我们需要配置这种“手动”灌溉系统,以最小化灌溉80米乘30米的田地所需的时间。任务要求找到一种算法来确定如何灌溉矩形田地,以便牧场主维护灌溉系统所花费的时间最少。田地中...

Global site tag (gtag.js) - Google Analytics