- 浏览: 36781 次
- 性别:
- 来自: 杭州
最新评论
Problem 21 05 July 2002 Let d(n) be defined as the sum of proper divisors of n (numbers less than n which divide evenly into n). If d(a) = b and d(b) = a, where a b, then a and b are an amicable pair and each of a and b are called amicable numbers. For example, the proper divisors of 220 are 1, 2, 4, 5, 10, 11, 20, 22, 44, 55 and 110; therefore d(220) = 284. The proper divisors of 284 are 1, 2, 4, 71 and 142; so d(284) = 220. Evaluate the sum of all the amicable numbers under 10000
package com.yao; import java.util.HashSet; import java.util.Set; /** * Created by IntelliJ IDEA. * User: shuimuqinghua77 * Date: 12-3-11 * Time: 下午7:55 */ public class Problem21 { public static void main(String[] args) { int top=10000; int result=0; Set<Integer> invalid=new HashSet<Integer>(); long start=System.currentTimeMillis(); for(int i=2;i<top;i++){ if(invalid.contains(i)) continue; int sum=sum(i); if(sum<=top&&sum!=i&&i==sum(sum)){ invalid.add(sum); result+=(sum+i); System.out.println("("+i+","+sum+")"); } } long end=System.currentTimeMillis(); System.out.println(end-start); System.out.println(result); } private static int sum(int n) { if(n==1)return 0; int sum=1; int middle=(int)Math.sqrt(n); for(int j=2;j<=middle;j++){ if(n%j==0){ int k=n/j; if(k==j) sum+=j; else sum+=(k+j); } } return sum; } }
发表评论
-
Problem26
2013-02-06 17:08 861A unit fraction contains 1 in t ... -
Problem25
2012-04-26 16:33 881package com.yao.Algorithms; ... -
Problem24
2012-04-26 14:12 778package com.yao.Algorithms; ... -
Problem23
2012-03-18 13:29 900A perfect number is a number fo ... -
Problem22
2012-03-17 23:13 767Using names.txt (right click an ... -
Problem20
2011-12-15 14:09 799package com.yao.shuimu.euler; ... -
Problem19
2011-12-09 14:07 716package com.shui.mu.yao.io.algo ... -
Problem18/Problem67
2011-12-04 20:20 891package com.yao.Algorithms; ... -
Problem16
2011-12-02 15:32 415package com.shui.mu.yao.io.algo ... -
Problem15
2011-11-29 23:28 527package com.yao.Algorithms; ... -
Problem14
2011-11-29 11:37 704package com.shui.mu.yao.io.algo ... -
Problem13_1
2011-11-21 14:07 586package yao.taobao.jj; publi ... -
Problem13
2011-11-19 23:51 564package com.yao.Algorithms; ... -
Problem12
2011-11-07 20:04 708package com.shui.mu.yao.io.algo ... -
Problem11
2011-11-06 19:38 1191package com.yao.Algorithms; ... -
Problem10
2011-11-03 20:14 410package com.shui.mu.yao.io.algo ... -
Problem9
2011-11-03 16:04 744package com.shui.mu.yao.io.algo ... -
Problem8
2011-11-03 12:38 590package com.shui.mu.yao.io.algo ... -
Problem7
2011-11-03 11:25 450package com.shui.mu.yao.io.algo ...
相关推荐
21. The maximum emission rate is 500 packets/sec and the maximum transmission rate is 350 packets/sec. The corresponding traffic intensity is 500/350 =1.43 > 1. Loss will eventually occur for each ...
21. 删除视图:DROP VIEW 语句(Problem 21) DROP VIEW 语句用于删除一个视图。 22. 修改表结构:ALTER TABLE 语句(Problem 22) ALTER TABLE 语句用于修改表的结构,例如添加或删除列。 23. 全文本搜索:...
Title: Computer-Based Problem Solving Process Author: Teodor Rus Length: 350 pages ...Chapter 21. Efficiency of Batch Operating Systems Chapter 22. Convenience of the BOS Chapter 23. Real-Time Systems
基于TEAM (testing electromagnetic Problem 21 基准模型,从实验和仿真计算两方面系统地研究 多谐波激励下变压器结构件杂散损耗建模与验证方法。考虑 线圈涡流损耗的影响,提出一种基于实验更准确地确定结构 件杂散...
C#,21根火柴棍问题(21 Matchticks Problem)的算法与源代码 21根火柴棍问题是西方经典游戏之一。 给定21根火柴,2个人A和B(比如:分别是计算机和用户)。 每个人一次可以挑选 1-- 4 根火柴。 被迫挑最后一根...
例如,在对TEAM Problem 21 (Model B) 进行计算时,可以采用以下形式的双重傅立叶级数逼近: \[ B_z(x,y) = \sum_{m=1}^{\infty} \sum_{n=1}^{\infty} A_{mn} \cos(u_m \pi x / a) \cos(v_n \pi y / b) \] 其中,$...
21. 〔用 手 或 器 具 〕击 ; 打 - hit 22. 立即;马上 - immediately 23. 陷入;参与 - get involved 24. 绷带 - bandage 25. 生病的;有病的 - sick 26. 膝;膝盖 - knee 27. 鼻出血 - nosebleed 28. 呼吸 - ...
1 Introduction......Page 21 --- Problem Solving & Traditional AI Problems......Page 27 POLyA’s five sTePs fOr PrOBLem sOLvinG......Page 28 PrOBLem-sOLvinG Techniques......Page 33 humAn WinDOW.........
Title: Problem Solving in Data Structures & Algorithms Using Java: The Ultimate Guide to Programming Author: Hemant Jain Length: 436 pages Edition: First Edition Language: English Publisher: ...
【标题】"0-1-knapsack-problem-master (21).zip" 提到的是一个与优化问题相关的项目,具体来说是0-1背包问题的实现。在计算机科学和运筹学中,0-1背包问题是一个经典的组合优化问题,它的目标是在容量有限的背包里...
在本压缩包"0-1-knapsack-problem-master (21)c.zip"中,我们可以预见到它包含了用C语言实现的0-1背包问题解决方案。 0-1 背包问题的定义如下:假设我们有一组物品,每个物品都有一个重量和价值,我们需要选择一些...
ASP.NET Core Recipes A Problem-Solution Approach(2nd) 英文epub 第2版 本资源转载自网络,如有侵权,请联系上传者或csdn删除 本资源转载自网络,如有侵权,请联系上传者或csdn删除
Designing an efficient algorithm to solve a computer science problem is a skill of Computer programmer. This is the skill which tech companies like Google, Amazon, Microsoft, Adobe and many others ...
"JEDEC JESD671D:2018 Device Quality Problem Analysis and Corrective Action Resolution Methodology" 本资源是JEDEC(Joint Electron Devices Engineering Council,电子器件工程理事会)发布的一份标准文档,...
### APIO2015 Problemset - Bali Sculptures #### 问题背景 在亚洲太平洋信息学奥林匹克(Asia-Pacific Informatics Olympiad,简称APIO)2015年的竞赛中,有一道名为“Bali Sculptures”的题目。这道题目的背景...
JEDEC JESD671D:2018 Device Quality Problem Analysis and Corrective Action Resolution Methodology - 完整英文电子版(21页).zip
压缩包中的 "0-1-knapsack-problem-master (21)c.zip" 文件可能是误写或者重复,正常情况下应该只有一个 "0-1-knapsack-problem-master (22)c.zip" 文件,其中包含源代码、测试数据、编译脚本等资源。解压后,我们...
为了验证所提出的方法,研究人员选择了Team Problem 21-A作为磁场测试模型,并对模型的测量损失与计算损失进行了对比分析。结果表明,计算出的磁通量密度Bx与实际测量值非常吻合。 此外,本文还提供了大型电力...