算法设计与分æž

算法设计与分æž

Info iconThis preview shows pages 1–4. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: 习习 1.1 5..习习习习 gcd(m,n)=gcd(n,m mod n)习习习习习习习 m,n 习习习. Hint: 习习习习习习习习习习习: 习习 d 习习 u 习 v, 习习 d 习习习习习 u±v; 习习 d 习习 u,习习 d 习习习习习 u 习习习习习习 ku. 习习习习习习习习习 m,n,习 d 习习习 m 习 n,习习 d 习习习习习 n 习 r=m mod n=m-qn习习习习习 d 习习习 n 习 r习习习习习习习 m=r+qn 习 n习 习习(m,n)习(n,r)习习习习习习习习习习习习习习习习习习习习习习习习习习习习 gcd(m,n)=gcd(n,r) 6.习习习习习习习习习习习习习习习习习,习习习习习习习习习习习习?习习习习习习习习习习习习习习,习习习习习习习习习习习? Hint: 习习习习习习 0<=m<n 习习习习习,Euclid 习习习习习习习习习习习 m 习 n, 习 gcd(m,n)=gcd(n,m) 习习习习习习习习习习习习习. 7.a.习习习习 1≤m,n≤10 习习习, Euclid 习习习习习习习习习习? (1 习) b. 习习习习 1≤m,n≤10 习习习, Euclid 习习习习习习习习习习? (5 习) gcd(5,8) 习习 1.2 1.(习习习习) P—习习 W—习 G—习习 C—习习 2.(习习习习) 1,2,5,10---习习习习 4 习习, f—习习习 4. 习习习习习习习 a,b,c, 习习习习习习习习 ax^2+bx+c=0 习习习,习习习习习习习习习习(习习习习 sqrt(x)习习习习习习习习) 习习 Quadratic(a,b,c) //习习习 ax^2+bx+c=0 习习习习习习 //习习:习习习 a,b,c //习习:习习习习习习习习 If a≠0 D←b*b-4*a*c If D>0 1 temp←2*a x1←(-b+sqrt(D))/temp x2←(-b-sqrt(D))/temp return x1,x2 else if D=0 return –b/(2*a) else return “no real roots” else //a=0 if b≠0 return –c/b else //a=b=0 if c=0 return “no real numbers” else return “no real roots” 5. 习习习习习习习习习习习习习习习习习习习习习 a. 习习习习习 b. 习习习习习习 解解解 a. 解解解解解解解解解解解解解解解解解 习习习习习习习习 n 习习习习习习 n 习习习习习习习 习习习习习 n 习习 2习习习习习 Ki(i=0,1,2...)习习习习 n 习习习习习习 n=0习习习习习习习习习习习习习习 习习习习习 Ki 习习 i 习习习习习习习习习 b. 解解解 习习 DectoBin(n) //习习习习习习 n 习习习习习习习习习习习 //习习习习习习 n //习习习习习习习习习习习习习习习习习习习习习习 Bin[1...n]习 i=1 while n!=0 do { Bin[i]=n%2; n=(int)n/2; i++; } while i!=0 do{ print Bin[i]; i--; } 9.习习习习习习习习,习习习习习习习习习习习习习习习习习习习习.(习习习) 习习习习习习习习习习习习习. 习习 MinDistance(A[0..n-1]) //习习:习习 A[0..n-1] 2 //习习:the smallest distance d between two of its elements 习习 1.3 1. 习习习习习习习习习习,习习习习习习习习习习习习习习习习习习,习习习习习习习习习习,习习习习习习习习,习习习习习习习习习习习习习习习习习习....
View Full Document

This document was uploaded on 04/10/2010.

Page1 / 44

算法设计与分æž

This preview shows document pages 1 - 4. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online