THE CLASSIC WORK EXTENDED AND REFINED The art of Computer Programming VOLUME 4A Combinatorial Algorithms Part 1 DONALD E.KNUTH
窖到远丝生 》代进 自手元抄毛春 Hownage入乃以
o f VI u me 4 mi ms Cf v1 u e4 f i ue s Aae i Cn tmd Top utall uhheh all gad hsh dop ffi gh nthb k y mthi dop ta,h nthb knthd ash i on mosnt nth uhasvtr -GERREALDB.F c th f hsvtai n aj whi .vh EN,IBRN"F"dBi F"ddto vb .g nth avnoi ai g shavnoi cj uo ghi uh a umasb cj tpb ai .ndk h,hsd xouufilh vob f1.i an.oi cj h,hi nu b ad fih hChvnhg no raeh xlavhk ai g b ai d a I nnlh xsofllhb mll fih xshuhi rhg mt.vt b ad fh uns.ej ai g ffiasshr 一Rr'siDCn rDie'RB.c th vg,hi npsh cj nth“Iph”asflpi vih Cd"(2o c th fihlg cj vob fl.i anosal al osntb u .u noo,aun no vo,hs .i a uj'Ih xaxhs os h,hi j a u.i'Ih flooer -s DG's 0'0Es )EA Cd(t k t.Ih Sounlj'a'aj un all b ai i hs cj xhoxlh .n tau fihhi b xsh uung pxoi b d b.i g ntan nth upvvhuujpl oi hu ash ntouh mto ta,h a i anpsal javpind jos uol,i'xpfifilh ur L.jh .u jpll cj xpffilhuk ai g mh ash vallhg pxoi no uol,h upvt au jarh nt somu ops madr -REe i D'fiB)s Cd(2to THE TILat Hr Ii A d nbi crnat rl nbi Agto (h Abb a dsini re lisno sgh ei g Tghdi a (hrr fg krno Phao rl Igrri hoL kr Ti EgmI i.nbi re lisro m (dbme i In hnmei ov finfin n rooornrno.gha Ai m (dbmAghmr I gsi nbim thg FA cr nbgm i Esnt t hnmei rssn TeinAiih nbi nAr gIlig ghsio rl igsb a(d itL q bih n D Pnbi li di ccihngwt rht rhi Agt Ir gTghdi onsb N-ghdlr Ig Chgmi vt I Pfil fiPxgha Toilm kdbmifi kgvy;omTt.nbi iogwr g nh cni cr nnh Abih n D 4L Mght rnbi Traliorl srme (hgrr Kgwigrni hog i a @snoci a ei rAL k fi egoe'mliorl qnicnTho ihI Ggwt g Ki Abih srme (hgrr kgwl Fevino gi crnaia.crmi mr f a(ffisnmnbgh rnbi L EBCihsi:Ai nbi f ght gTghdimihnoe nbgmesrhlr T rn nbi Igrri h? Crhcn fsnTh:Il cr.sgh onsb gh e ei Irnha qnPt? (Ehmmi gnTh:Hr A mght a(ffi ihng Tghdimi hnoe i Bc? (f)Gihi gnTh:Cgh gwg Tghdimihnoe 1.e 2.ooo ei fria ct crimgnGgwt? f)OInm gnh:q bgmg Tghdimihno mgEmi r Tm(hii rxe )d(fih gh re lisrfi Inhsnth r? Egsb rl nbi ci qni onThorn hornmr ei (hrilicnhd A iclisnrr-ghdlr Ig(kL
! " # $ % !! & !! ! !" # $ % &' ( ) * + ) Æ & , - . / & 0 - 1 )/ & , - 2 3 / & 4 - 0 / & 56 - 6 6 $& / , ) "
f Vl ure4i Vs r4 Aan4sf dre w T cen tfsj vvt.ieffo tn put la topeff eg tfTptffi tr nswsffl tnnen laT,wh ntmts wo pusp.d ut ff-Oz.d t is ffffep visi t oxGGvGf vnevtnw Tfipe ptfF veopeffor;ut pd e xoj acp bepu ye fipe tmtfiSffaj btntl ovepo.en bepu frpe el I S flaj btnt!ovepcEof Tsnwh.put'o sfil zoj acp i ueeot btpd ttff pde tmtflo en pde el I cEbap put vo sfil fo aot efft eg tsiur uao dt isfr(p Awtfsi ph Amt oepo eg tsi u vsnthr u ntscefffry svoe vnemto pusp put vnebvtj uso ffe cevapeff d utff -OB en ff yt fftnswd utfftmtn put ffaj btn egel I msato ffoxGEGf el I r qffeputn d enl o."sffygenl vsnfryoi sfftf Tpeffh d utff-OfD Vx en-OfD. gen cej t frptytn Dr efimrtnotw.d utff-l eto usmt puo gerj.6eh.r-smto uso gea fll sff tvtys ffp d sh pe i effopnai p s ca sbvt vvsi tj tfrpkott tf tni ot xu 2 ed j sfih tootffpswh I 3 tntfip vsnffyo.By.tfcW"epo.d utff-yned d BnO xE BaOxE BbOvBE Bt O xzFE B (CO xTlj vE BO xFffoffE kL BO'j jfFE B O'vBGTxFFE BO vz Btf j xfFE Bd O v BG'TGFFE BomO'Gjj zzf vz Bca O f BfBzBE ut msatoegBamsfll Bcad tnt I tptrj ffti bh 5 rP nskti,T?r"s wtp.sfil rj aT ff vFFf s fll vFFzEott nrot er fcs G rre3r 5 ceFICTTkvEzL xzx[xj FrH-otspS esputSsfrpoisvira spef cayytcpo puspBj yupbt neayuwh egenl tnkf-Fy Ado d utff p ffefrOtne kott tf tni ot zs fil ff ssi p pu 6 vntl Tpeff panffo eap pe bt bsorswh i ennti p Tffsw,ffed ffi sotar j ap ffe of vvt gerj as svvsntffpr ut vnebvtj eg"sfrygenl snnsfrytj tfrpo os of vvt ovti swi sot egs ytfitnsw i vsoo eg iej bffspenswi uswtfryto i swtl exact cover problemsr qff?ti peff Dvrvrx d t ous wopal h sffsyen puj iswtl fil sfli Tfry vff,o."d uTu s i efimt fntfip d sh pe ytfftnspt swcevapeffo pe cai u vnebvtj crf utff-OxB.cen tfsj vvt.puspj tpuel ffttl o pe vtngerj effw sbeap'vFF j tj enh siitooto gen tsiu "sfrygenl vsn snns frytj tfip pusp Afll ar uao put ns vat egB isffbt i ej vaptl Tffs ntsceffsbvt sj ea fip egpj t bh of vwh ytfftnspfry sweg put vsmfryo sffl iea fpfry putj r -epTt.ued trtn.puspBoa os huge faj btnY neayuwzl xF.ensbeapxzFF 5 dShtsnor k6 tiswpusps fi5 cShtsn'put ffaj btn eg 7ffopnai peffo tfti aptl vtn htsn bh s j si ufft puspi snnto eaps j weff ffopnai peffo vtn oti efil.ffsj twh xzB3zvFFFFrL utntgent plo i vtsn pusp put tfsi p msat egBca d so l tptnS j 7fftl bh cej t pti uffl'at puspl not fimewrt ytfftnspfry swegput snns frytj tfipor qffl ttl.putnt s j aiu.j aiu gscptn dsh pe iej vapt B.aolfry vewhffej sw sytbnsr ut Tffcpnai pnt j tpuel I toi nbtl fftftni t Bffttl oN kf-Lev tnspeflo. d uTu j sh ottj ftffii tfpbap btspo put ytfftnsptSsffl Sieaflp j tpuel bh s d uevv fry ssi pen egenl tn ZkkF-(oL sfil tmtfrd utf-OxBp naffo sbeap vF pj to gscptnr.ff put eputn usfil.put tfsip msat egB(d wnebsbwr fftmtn bt,ffed ff.tmtff soiej vaptno btiej t gsoptn sfil gscptnr 且t isff svoe1 effo tn“s frygenl vs万fryo pusp snt optimum Tff msneao d shor cen tfsj vvt.ovecobvt pe snns flyt of pttff vs Toegd t yupooxGKGGEGBB puspcsp ogh"sflycenl (oi efil peffs fil usmt put sl I peffs wnevtngh egbtfry fid tws
7 ) 8 ) 9 9 9 8 % % ' 9 ' * 8 ( : : 8 ; 1 " * * 0 < 5 = $ & 2 3 / " - ' ;' 77>' >?@>;*@' 9;?*?>?@' 7>>*99>*99*??' ' 9@' @?**' ;7?@@' ; ; 7?;@@' *;?*99?@9;99> ; $ & A8 + B 0 C . D @@* @@9' $@@9& 9E>@F . % %% $* & 6 $ 9&' D 8 " 1 G 7 ! # ; @@ " : 8 H I 9@ 9@@ +1J% $< !+1J%# 99;>9@@@@@@& 8 ( % ) 1 8 ; $*& Æ ' % % K$$ & & ; @ 5 " ( ; ; " ( !%
T opu ta hepgahd stth goi a n ha.andue MIa V ufunfu VI aVVIu4,i n(VWg a ha.andu hua:,I u Vu4 avu g.adue ▣I u aggvigwalu i we uwC nΠni bb k Ty m,v mb,T Tr k Tmkc v TTIb Ty T y Tr f T c my TTc c f V kJ 十 q中iIw,i vefMzVAxB+xTE吧+AAA叶FVAO FV Ax+AAA+x7TEN+zV AlEane VId gawWdm awuba:g.u,ua.fi l ar u ani Vuwt me is ha.andulB+B+AAAH ff O xx+xB+AAA+TM undu a.fi xBAxB+xz AB++AAA+x Af O x Axx+AA+xz A7+xBAR 5 i vui ruvlM u awwanpu:uVa knJl af g il ig T f iFih a:i np a.."anpsi ve gacwmpf is i weuwxEC;I u di nnudVnp .cuf aVlu hi Vi:is Vu ecapwa:fli, V aVni i vu VI an furu gacvf awu adi:g.ulu aVan4 gi mVMaf,u vuae svi:.uV \i wpl \Eane inu dan fli,Vava,cel is fb d c gi ffch.uy kSuu ubuwdfu TJ fl 1 aVavwanpu uf d do WVdno is-f xf VVfxxBG avu Vu inli ha.andue M nO a VIu funfu Vav og d do df abc ooue W;1u:abc m:gi ffch.u ra.m Virvnf inV\i hu zvEffy 8 nu fndl gacwnp-Vl uvu avu xvIFxBis Vu:-d v'7 v x'x 7 xBx'xz z x7 Tj Bxxz xv xF ff TBx'j xBxz x7 xx ff xF xvV kwJ i vu m\invuf Vnp 1mfVi n d \i aft si wVu "anpsi we gacwnpf VaV avu f:a..ufVane .avpufVa .ubcdi pwagl di weuvy I u anf,uvf si wCO v7 awu -=b-cbdecfgdoersfpgqtuwxv jklonhmirpsjqkhltiunmwvxM A xvwsquntkigrd-p-odgiknqsvxwutmrpohljcfbecbhmfejlG cs,u nfu VI u .ul\irvf -NbMVWM af Viae is VI u nm:huw xM MV'M7y fl ufl a..eddnff:an4 \iddll nalmuf si wdi:hoaVi wca.ig:o0aWi n m.aViwf udS Vi nf is V o dl ag \ivy 8 mwpi a.Ms di mvfuM a.hu \i fi.rufndl gvi h.u:f,cinV uba:mop i vu VI an a Vn4 gi vVi n is V ufgadu is a..gi ffc.u avwanpu:u\fy Orthogonal latin squares."uvf .iit hadt si wa i:uVaVVl u uaw4 ea4f is di:hmali wdfy gif\I m i nf vecvi n is adlmuf 8 Oana:f Rgsl goutbrn moah- gmortqagn gr phyntgagn kPawf Cx'TvzJ ad.neve an a:nfap gnoou a ri.m u 7M gapu 7'7Cfi;atu a..VIu aduf M cpf Mmmf Mane Iadtf svi:an i we mav4 eudt is g.a4cp dawef ane avwanpu VIu:m a flmavu fi VaVuadl vi,ane uadl di.m n di nVamf a..si nwr a.muf ane a..si nwfndfy an 4i mei c\W8 0ana:f fi.nvi nM fli,n m c cpyx in V u nubVgapulei uf uru i vuCcVubl cholf V'usm.gani g.4 is r a.mf ane is fmc'lf a.fi in hi V:am ecapi na.fy kP.uafu ein(V\rvn Vugapu m 4i mruparu Vd gvih.u:a Ww4yJ B4 xTlj a fc oawgnoou,af atap Vu vi mef is S\y PuluvfhmypNane cV da:u \i Vu allimWi n is V'u pwuaV:all'u:aVccan "ui nl ave muvy fi;I cvMsfcb i ffiduwf is fdb ec3uvun Vwant fMat un swi:fcb ec3uvunVvupa uVfM anV\i awd c a BR Bsi w avi n fi V aVuadl vi,ane uad di.m n,o.di nVac i nui ffiduwi s uadl want ane i nu is uadl vupc uly 2i,dan VIu4 ei cW Ni hi e4,af ah.u li
7 # ( - $ & 1 99 ;L *9 ;LL @9 ? @9 LL *9 *L 99 7' ;L ;LL ? L ; L L 7 ; ; L 9 ; L L ? L L 9 * L ; 7 + $ & " ;- 8 ' $G 7& ; ; 6/ 8 9;? 5 I @; I * * ; 9 9 * 7 > ; 9 @ ? 7 ; > ; 9 * ? @ $& . ) " 8 * $& * ) 6 % 5 "( . C) 56 ( $J- 79& 66 * * *- !8 ) ) # 0 / 56 ( - 1 $J ( ( & D 77> 66 G J " , !8% Æ 3 3 ; ; Æ 2 /# H