大整數乘法例子代碼 /* 遞歸邊界,如果是1位二進制數與1位二進制數相乘,則可以直接計算 */ /*累計做1位二進制乘法運算的次數*/ /* return (X*Y) */ /* 計算n的值 */ /* 把X和Y拆分開來,令X=A*2^(n/2)+B, 左移位運算,mod = 1<<(n/2) */ /* 計算XY=AC*2^n+(AD+CB)*2^(n/2)+BD */ /* 計算A*C,再向左移n位 */ /* 遞歸計算A*D */ /* 遞歸計算C*B */ /* 計算a21+a22,再向左移n/2位 */ /* 遞歸計算B*D */ /* XY=a1+a2+a3 */
上傳時間: 2015-05-19
上傳用戶:gyq
數字運算,判斷一個數是否接近素數 A Niven number is a number such that the sum of its digits divides itself. For example, 111 is a Niven number because the sum of its digits is 3, which divides 111. We can also specify a number in another base b, and a number in base b is a Niven number if the sum of its digits divides its value. Given b (2 <= b <= 10) and a number in base b, determine whether it is a Niven number or not. Input Each line of input contains the base b, followed by a string of digits representing a positive integer in that base. There are no leading zeroes. The input is terminated by a line consisting of 0 alone. Output For each case, print "yes" on a line if the given number is a Niven number, and "no" otherwise. Sample Input 10 111 2 110 10 123 6 1000 8 2314 0 Sample Output yes yes no yes no
上傳時間: 2015-05-21
上傳用戶:daguda
LCS(最長公共子序列)問題可以簡單地描述如下: 一個給定序列的子序列是在該序列中刪去若干元素后得到的序列。給定兩個序列X和Y,當另一序列Z既是X的子序列又是Y的子序列時,稱Z是序列X和Y的公共子序列。例如,若X={A,B,C,B,D,B,A},Y={B,D,C,A,B,A},則序列{B,C,A}是X和Y的一個公共子序列,但它不是X和Y的一個最長公共子序列。序列{B,C,B,A}也是X和Y的一個公共子序列,它的長度為4,而且它是X和Y的一個最長公共子序列,因為X和Y沒有長度大于4的公共子序列。 最長公共子序列問題就是給定兩個序列X={x1,x2,...xm}和Y={y1,y2,...yn},找出X和Y的一個最長公共子序列。對于這個問題比較容易想到的算法是窮舉,對X的所有子序列,檢查它是否也是Y的子序列,從而確定它是否為X和Y的公共子序列,并且在檢查過程中記錄最長的公共子序列。X的所有子序列都檢查過后即可求出X和Y的最長公共子序列。X的每個子序列相應于下標集{1,2,...,m}的一個子集。因此,共有2^m個不同子序列,從而窮舉搜索法需要指數時間。
上傳時間: 2015-06-09
上傳用戶:氣溫達上千萬的
電力系統在臺穩定計算式電力系統不正常運行方式的一種計算。它的任務是已知電力系統某一正常運行狀態和受到某種擾動,計算電力系統所有發電機能否同步運行 1運行說明: 請輸入初始功率S0,形如a+bi 請輸入無限大系統母線電壓V0 請輸入系統等值電抗矩陣B 矩陣B有以下元素組成的行矩陣 1正常運行時的系統直軸等值電抗Xd 2故障運行時的系統直軸等值電抗X d 3故障切除后的系統直軸等值電抗 請輸入慣性時間常數Tj 請輸入時段數N 請輸入哪個時段發生故障Ni 請輸入每時段間隔的時間dt
上傳時間: 2015-06-13
上傳用戶:it男一枚
光學設計軟件zemax源碼: This DLL models an nular aspheric surface as described in: "Annular surfaces in annular field systems" By Jose M. Sasian Opt. eng. 36 (12) P 3401-3401 December 1997 This surface is essentially an odd aspheric surface with an offset in the aspheric terms. The sag is given by: Z = (c*r*r) / (1+(1-((1+k)*c*c*r*r))^ 1/2 ) + a*(r-q)^2 + b*(r-q)^3 + c*(r-q)^4 + ... Note the terms a, b, c, ... have units of length to the -1, -2, -3, ... power.
標簽: described aspheric surfaces Annular
上傳時間: 2014-01-08
上傳用戶:yyyyyyyyyy
1 概述 1.1 編寫目的 本文檔的編寫目的是:詳細定義×××××軟件的總體功能;給出系統的結構設計,作為過程設計和程序編寫的依據。 1.2 參考資料 包括: a. 項目來源; b. 本文檔中引用到的規范和資料等; c. 列出這些規范和資料的作者、編號、標題、發表日期、出版單位或資料來源。 1.3 術語和縮寫詞* 列出本文檔中用到的專門術語的定義和縮寫詞,縮寫詞要給出中文譯名和英文全稱,常用的不需要定義。 2 需求概述 2.1 目標與需求 概述系統的特性和需求,擴充軟件需求說明中的信息,給出增加的細節,詳盡地指出對軟件需求說明中有關特性和需求做出的變更。 2.2 環境描述 描述運行軟件系統所需的軟、硬件環境;描述開發軟件系統所需的軟、硬件環境。 2.3 條件和限制 描述可能影響設計方案形成及實施的條件和限制。
上傳時間: 2013-12-18
上傳用戶:stvnash
/* * EULER S ALGORITHM 5.1 * * TO APPROXIMATE THE SOLUTION OF THE INITIAL VALUE PROBLEM: * Y = F(T,Y), A<=T<=B, Y(A) = ALPHA, * AT N+1 EQUALLY SPACED POINTS IN THE INTERVAL [A,B]. * * INPUT: ENDPOINTS A,B INITIAL CONDITION ALPHA INTEGER N. * * OUTPUT: APPROXIMATION W TO Y AT THE (N+1) VALUES OF T. */
標簽: APPROXIMATE ALGORITHM THE SOLUTION
上傳時間: 2015-08-20
上傳用戶:zhangliming420
by Randal L. Schwartz and Tom Phoenix ISBN 0-596-00132-0 Third Edition, published July 2001. (See the catalog page for this book.) the text of Learning Perl, 3rd Edition. Table of Contents Copyright Page Preface Chapter 1: Introduction Chapter 2: Scalar Data Chapter 3: Lists and Arrays Chapter 4: Subroutines Chapter 5: Hashes Chapter 6: I/O Basics Chapter 7: Concepts of Regular Expressions Chapter 8: More About Regular Expressions Chapter 9: Using Regular Expressions Chapter 10: More Control Structures Chapter 11: Filehandles and File Tests Chapter 12: Directory Operations Chapter 13: Manipulating Files and Directories Chapter 14: Process Management Chapter 15: Strings and Sorting Chapter 16: Simple Databases Chapter 17: Some Advanced Perl Techniques Appendix A: Exercise Answers Appendix B: Beyond the Llama Index Colophon
標簽: L. published Schwartz Edition
上傳時間: 2014-11-29
上傳用戶:kr770906
by Randal L. Schwartz and Tom Phoenix ISBN 0-596-00132-0 Third Edition, published July 2001. (See the catalog page for this book.) Learning Perl, 3rd Edition. Table of Contents Copyright Page Preface Chapter 1: Introduction Chapter 2: Scalar Data Chapter 3: Lists and Arrays Chapter 4: Subroutines Chapter 5: Hashes Chapter 6: I/O Basics Chapter 7: Concepts of Regular Expressions Chapter 8: More About Regular Expressions Chapter 9: Using Regular Expressions Chapter 10: More Control Structures Chapter 11: Filehandles and File Tests Chapter 12: Directory Operations Chapter 13: Manipulating Files and Directories Chapter 14: Process Management Chapter 15: Strings and Sorting Chapter 16: Simple Databases Chapter 17: Some Advanced Perl Techniques Appendix A: Exercise Answers Appendix B: Beyond the Llama Index Colophon
標簽: L. published Schwartz Edition
上傳時間: 2015-09-03
上傳用戶:lifangyuan12
上下文無關文法(Context-Free Grammar, CFG)是一個4元組G=(V, T, S, P),其中,V和T是不相交的有限集,S∈V,P是一組有限的產生式規則集,形如A→α,其中A∈V,且α∈(V∪T)*。V的元素稱為非終結符,T的元素稱為終結符,S是一個特殊的非終結符,稱為文法開始符。 設G=(V, T, S, P)是一個CFG,則G產生的語言是所有可由G產生的字符串組成的集合,即L(G)={x∈T* | Sx}。一個語言L是上下文無關語言(Context-Free Language, CFL),當且僅當存在一個CFG G,使得L=L(G)。 *⇒ 例如,設文法G:S→AB A→aA|a B→bB|b 則L(G)={a^nb^m | n,m>=1} 其中非終結符都是大寫字母,開始符都是S,終結符都是小寫字母。
標簽: Context-Free Grammar CFG
上傳時間: 2013-12-10
上傳用戶:gaojiao1999