- 浏览: 37060 次
- 性别:
- 来自: 杭州
最新评论
package com.shui.mu.yao.io.algorithm; /** * * @author shuimuqinghua77 @date 2012-12-02 * */ public class Problem16 { public static void main(String[] args) throws Exception { byte[] seed=new byte[]{2};/**如果是{1,0,2,4}*/ seed=getDigit(seed);/**那么转化后得到{4,2,0,1}便于乘法*/ byte[] result=new byte[]{1}; for(int i=0;i<1000;i++){ result = multiply(seed, result); } int sum=0; for(int i=0;i<result.length;i++){ sum+=result[i]; } System.out.println(sum); } private static byte[] multiply(byte[] multiplicand/**被乘数**/, byte[] multiplier) throws Exception { if(multiplicand.length==0||multiplier.length==0) { throw new Exception("被乘数/乘数为空!!!"); } if(multiplicand.length<multiplier.length){ byte[] temp=multiplier; multiplier=multiplicand; multiplicand=temp; } byte[] result=new byte[multiplicand.length+multiplier.length]; for(int i=0;i<multiplier.length;i++){ for(int j=0;j<multiplicand.length;j++){ result[i+j]+=(byte) (multiplier[i] * multiplicand[j]); } /**[29]->[9][2]进位**/ carry(result,1+multiplicand.length,i); } if(result[result.length-1]==0){ byte[] resultDest=new byte[result.length-1]; System.arraycopy(result, 0, resultDest, 0, result.length-1); return resultDest; } return result; } private static void carry(byte[] result,int length,int base) { for(int i=base;i<length+base;i++){ byte decade=(byte) (result[i]/10); if(decade>=1){ result[i+1]+=decade; result[i]=(byte) (result[i]%10); } } } private static byte[] getDigit(byte[] original) { byte[] render = new byte[original.length]; for (int i = 0; i < original.length; i++) { render[original.length - 1 - i] = original[i]; } return render; } }
发表评论
-
Problem26
2013-02-06 17:08 870A unit fraction contains 1 in t ... -
Problem25
2012-04-26 16:33 888package com.yao.Algorithms; ... -
Problem24
2012-04-26 14:12 788package com.yao.Algorithms; ... -
Problem23
2012-03-18 13:29 907A perfect number is a number fo ... -
Problem22
2012-03-17 23:13 776Using names.txt (right click an ... -
Problem21
2012-03-11 20:44 1209Problem 21 05 July 2002 Let ... -
Problem20
2011-12-15 14:09 810package com.yao.shuimu.euler; ... -
Problem19
2011-12-09 14:07 721package com.shui.mu.yao.io.algo ... -
Problem18/Problem67
2011-12-04 20:20 902package com.yao.Algorithms; ... -
Problem15
2011-11-29 23:28 539package com.yao.Algorithms; ... -
Problem14
2011-11-29 11:37 714package com.shui.mu.yao.io.algo ... -
Problem13_1
2011-11-21 14:07 594package yao.taobao.jj; publi ... -
Problem13
2011-11-19 23:51 573package com.yao.Algorithms; ... -
Problem12
2011-11-07 20:04 714package com.shui.mu.yao.io.algo ... -
Problem11
2011-11-06 19:38 1203package com.yao.Algorithms; ... -
Problem10
2011-11-03 20:14 417package com.shui.mu.yao.io.algo ... -
Problem9
2011-11-03 16:04 753package com.shui.mu.yao.io.algo ... -
Problem8
2011-11-03 12:38 594package com.shui.mu.yao.io.algo ... -
Problem7
2011-11-03 11:25 461package com.shui.mu.yao.io.algo ...
相关推荐
16. The delay components are processing delays, transmission delays, propagation delays, and queuing delays. All of these delays are fixed, except for the queuing delays, which are variable. 17. a) ...
16. 子查询:嵌套查询语句(Problem 16) 子查询是指嵌套在另一个查询语句中的查询语句。 17. 插入数据:INSERT 语句(Problem 17) INSERT 语句用于将数据插入到表中。 18. 正则表达式过滤:REGEXP 操作符...
- **旋转变压器电路**(Problem 16.69): 讨论了旋转变压器的工作原理。 - **计算允许的AM广播频段内的电台数量**(Problem 18.63): 探讨了频谱管理的相关技术。 - **语音信号——奈奎斯特速率**(Problem 18.65): 讨论...
Chapter 16. Software Tools for Correct Program Development Part 5 Computer Operation by Problem Solving Process Chapter 17. Using First Computers to Solve Problems Chapter 18. Batch Operating System ...
AIX 6 System Administration II: Problem Determination (Course code AU16) Student Exercises with hints 自测练习题
### Problem 16 #### Part (a) This problem deals with matrix algebra, specifically the inverse of a sum of matrices. Given nonsingular matrices \( A \) and \( B \) of the same order, the equation: \...
**观测数据**:六个地震站记录了地震波到达的时间,这些地震站位于矩形网格上,坐标分别为:(3km, 15km),(3km, 16km),(4km, 15km),(4km, 16km),(5km, 15km),(5km, 16km)。地震波到达时间的观测值为:3.12秒,...
16 Random Walks on Graphs & Monte Carlo Methods......Page 298 TheOreTicAL APPLicATiOns......Page 301 random Walks on Graphs......Page 303 mArkOv chAins AnD mOnTe cArLO meThODs......Page 306 references...
int M, g, a[20] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20}, ag[20], c[20]; ``` - 初始化数组`a`,用于存储可能填入环中的数字。 - `ag`数组用于标记数字是否已被使用。 - `c`...
#### 第16章:STL异常类(p.917) 标准模板库(STL)是C++的一个重要组成部分,提供了大量高效的数据结构和算法。本节讨论了STL中用于处理错误情况的异常类。 - **异常**:表示程序执行过程中发生的非正常事件。 - ...
#### Chapter 16: Standard Template Library (STL) This chapter covers the Standard Template Library (STL), a powerful set of C++ libraries: - **STL Containers**: Explanation of STL containers, such ...
Chapter 16. Searching and Sorting. Chapter 17. Linked Lists. Chapter 18. Stacks and Queues. Appendix A. Reserved Words. Appendix B. Operator Precedence. Appendix C. Character Sets. Appendix D. ...
CHAPTER 16: BRUTE FORCE ALGORITHM CHAPTER 17: GREEDY ALGORITHM CHAPTER 18: DIVIDE-AND-CONQUER, DECREASE-AND-CONQUER CHAPTER 19: DYNAMIC PROGRAMMING CHAPTER 20: BACKTRACKING AND BRANCH-AND-BOUND ...
#### 第16章:标准模板库异常处理 - **STL 异常类**:探讨了如何使用STL提供的异常处理机制来处理运行时错误。 #### 第17章:模板编程问题 - **编译带有模板的程序**:讨论了模板编程中常见的一些编译问题及解决...
computer network 5th andre problem solutions
据说着名犹太历史学家 Josephus有过以下的故事:在罗马人占领乔塔帕特后,39...然而Josephus 和他的朋友并不想遵从,Josephus要他的朋友先假装遵从,他将朋友与自己安排在第16个与第31个位置,于是逃过了这场死亡游戏。
C++ Programming: From Problem Analysis to Program Design By 作者: D. S. Malik ISBN-10 书号: 1337102083 ISBN-13 书号: 9781337102087 Edition 版本: 8 出版日期: 2017-02-13 pages 页数: 1491 Contents ...
而进阶学习者则可通过"Chapter13"和"Chapter16"学习到面向对象编程中的核心概念,例如对象和类的构建、继承、多态性等。 "readme.txt"文件在源码学习中同样扮演着重要角色,它通常会包含编译源码时所需的重要信息,...