CONCOURS COMMUN POLYTECHNIQUE 1997 Informatique
Transcription
CONCOURS COMMUN POLYTECHNIQUE 1997 Informatique
CONCOURS COMMUN POLYTECHNIQUE 1997 Informatique (option MP) = ∨ ! "$#&%'%)($*,+-%.* / 01+ %)23.+*,41(5%'6879: ; = <>= " ?)A@ + B(5%)%)+-4,CCD+-%)B7 EGFH7IKJ'7*L6HM 2NBIK41IK7 O ∧ P ∨ O ∧ P = Q$RTSLU " V.AW (5%)B Q$RTSLU = ∨ ! ∧ ! ∨ ∧ ! ∧ ! = ∧ ! ) ) ] ( [( ] [( 6.7>01+ IK($^8*,7Z687Z38+N^HBb)75" )∨ X)ZY\[]U = ∧ ! " @ M (5+]CD4,C&CD7*,IK($^5_)7 68(5%)B +^a`)($^8* $cdef\Hgihjk g l)mn@ M +N^8*,(5J'+N*o7 IK7B(5%)%)+-4p*L017-CqJ'($*Cq687Z01+Zr(5IKJ'7 l8ltsvu O u8l.l)svu.Ks ($w s IK7jF)IK2-CK7%.*,7Z0v+Zr 7IKJ'7j*1^HIK7Z687yx0177%)75" u)mnW +-%zCq01+ 682jr41%)4p*,4v(5%T687 { (5%|FH7j^.*zFHIK7%)6.IK7 } = ε 7j*-~^)%'J'($*L^H701B(5%)5^)7>6.7 Yq{ BN7>^H4)F)IK($^]_)7Z5^H7 ∈ " @ +C^H4p*,7 7-C *z^)%)7 C^H4p*,7>BIK(54,CCK+$%8*,7Z687 CK($^zC m 7%zCK7J`)017-Cq6.7>0,M 7%zCD7J`)017r 4v%)4 i B-M 7-C*L68(5%)By^H%)7 C^H4p*,7 C*,+*,41(5%)%H+$41IK75" W 7F)0p^tC { CD4 z z]{ *o($^zCq0v7$C*,7IKJT7-CqZFH+$I *o41Iq65^'IK+-%)3\CD(5%8*\238+N^Ha6HM +F)IK-Cq0v+ 6.2jr41%)4p*o41(5%'IK2NBj^HIKIK7%.*,7Z687 ")8(54p*Li^H%'2*o+N*L6.7 7j*z}^H%aF)IK2jr4187Z687 Y F)7IKJ'7j*1*,+-%.*L6)M +N*v*,741%)68IK7Zz")84nz7-C *\0v7Z%)(5J`)IK7Z687Z0v7*v*,IK7-Cq6.7} { +$01(5IC ∈ 7* 7-C*L68(5%)BZ01+ IK2j^H%)41(5%'687$C7N%tCD7J`)017-C " W (5%)B { CK4 zA z]{ +-01(5IC z " mn@ M +N^8*,(5J'+N*o7 P 7-C *\IK7jFHIK2-CD7%.*,2>B4 m 687-CCK($^zC l u lNKu u u l l $( ^)I017Z682j*,7IKJ'41%)4,CK7I { (5%'BN(5%tC*,I ^H4p*z^H%T+^.*o(5JT+*,7Z68(5%.*017-Cd2j*,+*CCD(5%8*687$CCK($^zC m 7%zCK7J`)017-Cd687 ∪ { } "z8(5%2j*,+*41%)4¡*,41+$0L7-C* { 7*6.7 { } F)IK(5Bb)77%¢FHIK(5Bb)7 { (5%Bb)7IKBb)7£0oM 7%zCK7J`)017£687-CT2j*,+*CT5^)70,M (5%¢FH7^8*+N@ *v*,741%)68IK7££FH+$I *o41I'6)M ^H%7N%tCD7J`)0176)M 2j*,+N*¤CT682¤¥682jr 4v%)4ZF)+-Ia^)%)7 *,IK+$%tCD4p*o41(5%¢B(5IKIK7-CFH(5%)68+$%.* A^H%)7017j*1*oIK72_)7%.*v^)701017J'7%.*C ^H4¦_)4176.7 ε " 7-CT2j*,+*C|*,7IKJ'41%)+^)§CD(5%8*BN7j^H¢5^)4 B(5%.*o417%)%)7%.*0,M 2j*,+N* *"¨ % (`.*,417%.*L+$4v%zCD4 l l { { u u l u { lNu ?)q@ +aB(5%zC *,I ^)Bj*,4v(5%£65^6.2j*,7IKJ'41%)4oCD2a687 P IK7_)417%.* { F8^H4,CD5^tM +^)Bj^H%)7i*,IK+-%zCK4p*,41(5%%)7iFH+$I *&6.70,M 2*o+N* 687 P>{ TIK7JaFH01+$B7IZ017-CZ2j*,+*CZ6.7 F)+-IZ017-CZ2j*,+*CiW ©. {\Kªa{ © {\ªa{ ©8 {\Kª { CD+-%zCZBb)+$%)387IZ017-Cy*,IK+-%zCK4p*,41(5%zC 7j*68(5%) B«¯ CD41JaFH017J'7N%8*T*,IK+-%zC r (5IKJ'7I 017-C 2*o+N*C . { { 8ZW 7%2j*,+N*¤C *,7IKJ'41%)+N^Hz" 7¬P r+$(5%®FH0p^zC3.2%)2IK+$0v7 BN7§CD(5Y%8 *0v7$C2*o+N*C6870,M 7N%tCD7J`)P017 5^H4CK(5%.**,IK+-%zC r (5IKJ'2-C7%°2j*,+N*¤C±*o7NIKJ'41%H+N^Hn" (5%)B017 6.2j*,7IKJ'41%)4oCD2>6.7 IK7BN(5%H%)+N²1*L017>01+$%H3.+-3.7 IK2jrO 7j*L410z7%T7-C *L6.7>JT³J'7Z687 " $-\.,efy #%'68Uy4,C*o 41%)35^)+-%.*L017-C F)+-I *,417-CqB(5%.*,7%)+-%.*H9a6.7>B7N0v017-Cq%)7Z0v7ZB(5%.*,7%)+-%.*zF)+]C { 5( %'(`.*,4v7N%8* P OK©9 ª ∪ P O ∪ 9 P O "8¨ %%H($*,7IK+i5^)7 " P O ∈ PO P O ^H4,CK^H7 9 ∉ { 0,M +-6¥(5%)Bj*,41(5%'6879a Bb)+$5^H7yFH+$I *,417>6.7 IK2+$014,CK7y^H%)7&`)4 ¥7Bj*,41(5%'687 P O C ^HI\9 PO " W M ($w'017>IK2$C ^H0p*,+N*L687JT+-%)682" «my 7j* = " W M +F)IK-Cq01+ 5^H7$C *,41(5%aFHIK2BN2687%.*,7 { ($*,(5%zC U = U M ∪ {9 } +j_)7B U M = ∑ ∈P = ∑ ∈P + W 7ZJ'³J'7 { 7j*\7%'B(5J`)41%)+$%8*\B7-Cq238+$014p*o2$C " ∑ O ∈P ? + = ? − ? + − = − + ? − ∑ " ∈P − """""""""""""""""""""""" ? = + ? + ? − "(5J'JT7. !|{ (5%a*,IK($^5_)7 = = ? − " function ajouter(x:integer;e:L_Liste):L_Liste; var l:Liste; q:L_Liste; begin if e = nil then ajouter := nil else begin l:=L_tete(e); q:= L_queue(e); ajouter:=L_cons(cons(x,l),ajouter(x,q)); end; end; # function parties(e:Liste):L_Liste: begin if e = nil then parties:=L_cons(nil,nil) else parties:=L_concat(parties(queue(e)),ajouter(tete(e),parties(queue(e)))); end; $ % $ function ajouter_objet(x:integer;e:T_Liste):T_Liste; var l:Triplet; q:T_Liste; begin if e = nil then ajouter_objet := nil else begin l:=T_tete(e); l.ensemble:=cons(x,l.ensemble); l.somme_poids:= l.somme_poids + p(x); l.somme_volume:= l.somme_volume + v(x); q:= L_queue(e); ajouter_objet:=T_cons(l,ajouter_objet(x,q)); end; end; function chargement(e:Liste):T_Liste: var T:Triplet; begin if e = nil then begin T.ensemble:= nil; T.somme_poids:= 0; T.somme_volume:= 0; chargement:=T_cons(T,nil); end else chargement:=T_concat(chargement(queue(e)), ajouter_objet(tete(e),chargement (queue(e)))); end; procedure sac_a_dos(PTAC,VTAC:real;l:Liste;var t:Triplet); var tl:T_Liste; meilleur_t:Triplet; begin tl:=chargement(l); meilleur_t.somme_poids:= 0; meilleur_t.somme_volume:= 0; while tl<>nil do begin if ( ( T_tete(tl).somme_volume > meilleur_t.somme_volume ) and ( T_tete(tl).somme_volume <= VTAC ) ) or ( ( T_tete(tl).somme_volume = meilleur_t.somme_volume ) and ( T_tete(tl).somme_poids > meilleur_t.somme_poids ) and ( T_tete(tl).somme_poids <= PTAC ) ) then meilleur_t:=T_tete(tl); tl := queue(tl); end; end; { =[ ] ? { { V {? { { =[ ] =[ ] - ? { =[ ] =[ ] V { V {? { ] =[ V " ] =[ function terme_suivant(n:integer;u:Liste):Liste; begin if tete(u) < n then terme_suivant:=cons(tete(u)+1),u) else terme_suivant:=cons(tete(queue(u))+1),queue(queue(u))); end; ¤O ¨ « % C .^ 8F )F 8( KC Z7 v4 NB z4 5 )^ >7 10 y7 o* N7 KI ' J 7 C H^ ¦4 )_ $+ 8% \* -7 C L* NB -+ 10 jB )^ v0 j+ )` 10 7 { -B M -7 C L* 86 14 KI Z7 5 )^ 7 ? m " procedure sac_a_dos_bis(PTAC,VTAC:real;l:Liste;var t:Triplet); var i:integer; meilleur_pds, meilleur_vol:real; tr:Triplet; begin tr.ensemble:=cons(1,nil); tr.somme_poids:= p(1); tr.somme_volume:= v(1); meilleur_pds:=p(1); meilleur_vol:= v(1); for i:=1 to deux_puissance(n)-2 do begin u:=tr.ensemble; tr.ensemble:=terme_suivant(u); if tete(u) < n then begin tr.somme_poids:= tr.somme_poids+p(tete(u)+1); tr.somme_volume:= tr.somme_volume+v(tete(u)+1); end else begin tr.somme_poids:= tr.somme_poids-p(tete(u)) -p(tete(queue(u)))+p(tete(queue(u))+1); tr.somme_volume:= tr.somme_volume-v(tete(u)) -v(tete(queue(u)))+v(tete(queue(u))+1); end if (tr.somme_volume > meilleur_vol ) and (tr.somme_volume <= VTAC ) ) or (tr.somme_volume = meilleur _vol ) and (tr.somme_poids > meilleur_pds ) and (tr.somme_poids <= PTAC ) ) then begin meilleur_pds:=tr.somme_poids; meilleur_vol:=tr.somme_volume; t:=tr; end; end; end; R l .7%B(5%zC *,I ^H4,CD+-%.*B(5J'J'7 6.+-%zC01+ DC 5( ¡0 .^ ,* v4 5( z% qC $( 8F ,* 14 ' J $+ 10 -7 jC " ^ )% 7 function enumerer H @ o4 C ,* 7 { 14 0 DC 7 KI $+ ¡4 \* r $+ B 14 10 7 86 7 86 5( )% )% 7 I 10 + 10 ,4 C ,* 7 7 . Hb N+ t^ C ,* 4 )_ i 7 86 -7 C $ % N+ 8F HF N7 0 ± 10 + procedure cons " $( ,* 5( z% C ϑ 7j* ϑ 01+ )b -+ H^ 7 N+ 8F )F 7 >0 £ 10 + function terme_suivant B 5( .% ,* 14 7 .% * H^ B(5J|FH01784p*,2Z687-C FHIK(5BN265^)IK7-C cons j7 * L_cons KI -7 C )F 7 jB ,* ¦4 )_ 7 ' J 7 .% K* " 10 5( I C Q O = ? ϑ + ϑ + O ? − ? O ϑ + ϑ = O ? " q@ +aB(5JaFH017.4p*o2 Q O ) 6.701+ function ajouter )_ 2 KI p4 r 14 7 10 a + KI 7 10 + ,* 14 5( % 86 i 7 KI 2 jB )^ KI KI 7 )% B 7 Q O = Q O − + ϑ + ϑ ")¨ %7% 6.265^)4¡* Q O = O ϑ + ϑ + Q O " @ + B(5J|FH01784p*,2 Q O H 6.7>01+ function parties )_ 2 KI p4 r 14 Z7 10 + KI 7 10 + ,* 14 5( « % .6 7 KI 2 jB )^ KI KI 7 )% B 7 Q O = Q O − + Q O − " W M ($w Q O = − Q O + Q O = O − O ϑ + ϑ + Q O + Q O = O " ? ∑ = @ +¢B(5JaFH017.4p*o2¬687 01+ function enumerer -7 C ' * 86 5( )% B ,* KI -7 C C 8^ HF N2 KI v4 7 H^ KI ¢ 7 B 7 10 10 7 .6 7 10 + function parties " d 7 B 4 C M 7 5 )F 10 v4 H^ y7 HF $+ I 10 y7 r -+ p4 L* H^ Z7 B j7 1* ,* >7 .6 7 KI )% 14 KI >7 KI 7 HF 8( KC 7 C )^ I 10 y7 HF KI 14 )% B p4 HF Z7 86 Z7 86 14 B )b $( ,* 5( ' J 14 7 ¤O 86 ¦4 )_ ,4 KC 7 I HF $( )^ I KI 7 .3 H% N7 I "
Documents pareils
Source
• In California there are both public and private institutions of higher education. Private
institutions can be for profit or non-for profit. Public institutions include the University
of Californi...