- 1、有哪些信誉好的足球投注网站(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。。
- 2、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 3、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
- 4、该文档为VIP文档,如果想要下载,成为VIP会员后,下载免费。
- 5、成为VIP后,下载本文档将扣除1次下载权益。下载后,不支持退款、换文档。如有疑问请联系我们。
- 6、成为VIP后,您将拥有八大权益,权益包括:VIP文档下载权益、阅读免打扰、文档格式转换、高级专利检索、专属身份标志、高级客服、多端互通、版权登记。
- 7、VIP文档为合作方或网友上传,每下载1次, 网站将根据用户上传文档的质量评分、类型等,对文档贡献者给予高额补贴、流量扶持。如果你也想贡献VIP文档。上传文档
查看更多
a的n次方的快速算法(A fast algorithm for the n power of a)
a的n次方的快速算法(A fast algorithm for the n power of a) EN binary power The power of n a for solving this problem, many people see after all do not think what content! The first time I think this problem would not have what content, but then think carefully, there really is a learning oh! See if we find A8, there are two kinds of methods 1.a8 = a * a * a * a * a * a * a * a need to compute 7 multiplication 2.a = 8 (a * a * A * A) (where A = a * a) need to compute 3 multiplication An algorithm for such a simple calculation step difference is a big difference, so for a common n representation The general method of solving? After many days of thinking, no results, today suddenly in a book to see about this algorithm, exultation. The solution to tidy up a bit, and then gives the specific code. The idea of the algorithm General for a (2x + b) = a2x * a B So there is (b = 0): a = 2x + B (AX) 2; (b = 1): a = 2x + B (a x) 2 * a; For an, the first N binary representation to write, so An = a (N1 N2 N3 N4 (2) =..)... Then we can from left to right as shown in the following table (when n = 13, 1101) N bit One One Zero One Multiplicative A A2 * a = A3 (A3) A6 = 2 (A6) 2 * a = A13 The first code (using Java, with the function call, failure effect) Package alg; Public class {AN Public static final int EXIT = 3; Int a; / / base Int bin; / / index Public StackInteger s; Public AN (int a, int bin) { This.a = a; This.bin = bin; S = new (StackInteger); S.push (EXIT); / / as a sign of the last ToBin (bin); } Public void renew (int a, int bin) { This.a = a; This.bin = bin; S.push (EXIT); / / as a sign of the last ToBin (bin); } / / is from left to right Public int (leftToRight) { Int i; Int result = 1; While (true) { (I = s.pop); Switch (I) { Case 0: Result = result; Break; Case 1: Result = result * result * a; Break; Case EXIT: Return result; } } } Public int rightToLeft (int a) { Return 0; } / * * * the decimal into binary stack * * @param ten * / Public StackInteger toBin (int ten) { Int te
您可能关注的文档
- 7、相邻体积单位之间的进率(7, the rate of entry between adjacent volume units).doc
- 7个性格模式(7 personality patterns).doc
- 7名中国研修生遭管理日企欠薪 法庭展首次辩论维权(7 Chinese trainees have been punished, Japanese enterprises wage Court Exhibition for the first time debate rights).doc
- 7大赚钱金点子(7 big money tips).doc
- 7的口决.(7 mouths never do).doc
- 7天酒店 放羊式管理(7 day Hotel sheep type management).doc
- 8.杰出经营者的高明之处(8., outstanding operator's brilliance).doc
- 6大型电视辩论赛方案(6 large-scale TV debate program).doc
- 8.语病分析(8. error analysis).doc
- 800mw汽轮机末级叶片断裂原因分析及防范措施(Fracture analysis and preventive measures of last stage blade of 800MW turbine).doc
- baseadapter适配器(baseadapter适配器).doc
- bandari 班得瑞《garden of dreams 梦花园》[ape][325m](班得瑞班得瑞《梦花园梦花园》[猿] [ 325m ]).doc
- b2科目一的 技巧(B2 subjects one skill).doc
- b8159-87矿用一氧化碳过滤式自救器(B8159-87 carbon monoxide filter self rescuer for mine).doc
- a股蓝筹股(A blue chip).doc
- bbd和ddx公式代码(BBD and DDX formula codes).doc
- bb不会爬 多是代劳惹的祸(BB will not climb is the fault of the evil).doc
- bcb读写文件(BCB read and write files).doc
- autocad的绘图技巧(八)(AutoCAD drawing skills (eight)).doc
- bcdedit_set参数(bcdedit_set参数).doc
文档评论(0)