File chuong trinh MAXISEQ.[r]
(1)THI CHON HOC SINH G I ~ I Q U ~ C GIA LOP 12 THPT NAM 2007
ifi ' I J Mdn: TIN HOC ,.A? ! ,
Thth gian: 180 phdt (khdng kd th&i gian giao d&) 'Nghy thi: 08/02/2007 i:iiA :u, , : L .! L -
@k thi gbm trang) & I ; ; ! : ' , -
D ~ U * duqc thay th& b3i PAS ho#c CPP ciia ng8n ngit lgp trinh d q c sir dgng tumg
rkng lt'i Pascal hogc G t t ' d
, p 1 ,+ *, ,; p b,:, I L C ~ 1;:: &-L i: , , - t
HISy I@ trkh gidi cdc b todn sau: t 'L - t i , , - q i - ,< * ; ! ~ n ( , i t -
i f f i I . . <*
File k%!t quh MAXISEQ.OUT SMARKET OUT ROBOT OUT B a i
Bai 2
BAi 3
Bai (6 diem) D l y khbng giiim d8i nhst
c , '
Cho day s6 nguyCn ducmg al, a= , a,,
T6n bdi D & y kh6ng
g i h d&i nhht
sigu th/ may m h
Robot & ho8
a h ai+l, , a,thbarnk at,<ai+l < Ia,,
vbi 1 I i l j I n duqc g ~ i lh aEy con khdng gidm c k day s6 da cho vA khi 66 s6 j-i+ 1 duqc ggi 18 &i c b day nhy
Yeu c h : Trong s6 chc d Q khdng g i h c b &y s6 Bs: cho ml circ phgn tir c b nb d&u
thuijc diiy s6 {uk) xb &h bbi ul = 1, uk = uk.l+ k (k 2 2), hgy tim diiy c6 do diii 1hnhbt
File chuong trinh MAXISEQ *
a ,- : , SMARKET *
ROBOT *
Di2 lieu: V b tir file v h bin MAXISEQ.INP
File di2 li@ vdo MAXISEQ.INP SMARKET INP
ROBOT INP
Dbng dhu tiCn chira mot sb nguysn duang n (n 9 lo4); ' I ' ,
: ? Dbng thti i tmng n dbng tiip theo chua mot s6 nguyen duang a* (ar 5 lo8) 1h s6 hqng thfi
, 6 : , i c h d % y d i b%cho, i = 1, 2, , n
~ t quH: Ghi ra file v h b h MAXISEQ.OUT s6 nguyen d 1A do dai c b day khdng g i h
tim duqc (quy u6c r h g nbu khang c6 day n2io th6a m h di&u ki$n &it thi d = 0)
Vi dy: Cho d8y s6 u5 8 phgn ttc 2,2007,6,6,15,16,3,21 C b diiy w n khang g i b c h day s6 68 cho mh c8c p h k tvt c h n6 dbu thuoc day {uk) 1h: 6, 6, 15 vh 3,21 (vi 2.42 = 3, y = 6, u5=15, u6=21) ~ i i ~ c h t i m lh6,6, 15 c6 dodhi183
(2)B i i (7 dibm) Si6u thi may m i n
An bugc mbi tham gia trb chai "SiCu tG may m k ' ddi truy&n hinh Z
duqc dat tmbng quay truy6n Mnh c6 n mat himg duqc danh s6 N 1 thir i duqc ni&m y&t gih la ci dong, i = 1, 2, , n Theo th& 14 c h trb c
c h k t&g mot ththt rnua h g c6 gi8 trj i s d8ng v8 ph&i d h g h&t s6 tikn the ndy d& rnua hAng sieu thj v&i diku kitn m@ h t g thu i chi duqc rnua v6i s6 luqng nhi&u d t18 mi,
i = 1,2, ., n An sg 18 ngu& thing cuoc n&u ttim duqc t6ng s6 chch rnua h h g th6a miin y8u
du @t vii chi mot chch rnua h h g nbu co
Y&u cfiu: Hily gi6p An trb thMngvbi t h h g cuoc cho b y biit tnr&c c b gih td n, s, c, vA m ~ ( S n S 0 ; ~ s ~ ; ~ c , ~ ; ~ m , ~ 0 ) v ~ ~ = , , , n
Dik Ueu: V&o tik file v b b h SMARKET.INP
Dbng dhu ti&n chua hai s6 nguyen duang s v8 n;
Dbng th3 i trong n dbng ti$ theo chira hai s8 nguy&n duung ctvA mi v6i i = 1,2, , n
K&t qu8: Ghi file v5in bAn SMARKET.OUT
* Dbng &u4ti&n ghi s6 nguy&n d 18 t8ng s6 c k h rnua h h g tlm duqc;
N&U d Z 1 thi dbng thii hai ghi mot chch rnua h h g tim d&c l i mot d5y n s6 nguyen, d6 s6 hqng thir i 18 s6 luqng m$t h h g thii i rnua dugc c k h mua h h g nhy,
i = 1,2, , n
Hai s6 liCn tiip tr&n mot dbng file dB lieu v& file k6t quii chch it nh6t mot &u chch
Vi dy:
I SMARKET I N P I SMARKET OUT 1
TrEn mot mwg lubi giao thdng c6 n nfit, c8c nut duqc cbhh s6 N dkn n,vA giba bai nut bht
kjr c6 khQng qutt mot duIhtg ndinvc tiifp ( d u h g n6i tqrc tiip 11 mot d u h g hai chiiu) Ta g ~ i
d u h g di ttr nnlit s din nut t ld mot diiy citc nct v h cAc d u h g n6i tqrc tibp c6 dqng:
trong 66 ul, u~ , uk la c b nlit mqng lubi giao thiSng, ei la dutmg n6i hyc ti6p giDa nut
u, v4 u ~ l (kheng 06 niit tj d o x d t hi&n &u ban mot 1h trong &y trkn, j = 1,2, , k)
~ i & t &ng mmg lu6i giao thsng duqc xtt lu6n c6 it nhh mot d u h g di tir nfit 16n nut n
Mot robot chfra &iy binh v&i w dun vi n h g lugng, c h di N tqun c h hoa d@t tqi nut d&n nui xay hoa h o w b nut n, th&i gian it nhht c6 th& Thbi gian vii chi phi ning luqng d& robot di tr&n d u h g nbi tqrc ti& ttr nut i bkn nut j t u m g img 18 tu v8 cv (1 I i, j I n) Robot
lp
chi a5th& di duqc tr2n d u h g no1 tqrc tikp tir nut i din nut j n&u n5ng luqng cbn 1~ binh c h h kh6ng it ho11 cu (1 5 i, j 5 n) N&U robot di d n mot nut c6 tram ti$ n h g luqng (mot nGt c6 th6 c6 ho@c khdng c6 t r w tikp n h g l u p g ) thi n6 dong duqc ngp &Ay n h g l u p g v8o b ' i chtra vbi thbi gian npp coi nhu kh6ng b h g k&
(3)robot bi duqc tr2n mot d u h g di tir niit din nrlit
Dbng dip ti&n chira mot s8 nguyen ducmg n (2 5 n 5 500);
Dbng th hai c h h n s6, tmng 66 sb thir j b h g hoac 0 tumg h g b n ~ t j cc6 hoec khangc tqunti&pnilng 1ugng(j = 1,2, , n);
Dbng th ba chira s6 nguyen duung m (m I 30000) lA s6 b u h g n6i tryc tikp c6 trong
mwg lu giao th8ng;
Dbng th k sb m dbng tihp the0 chira s6 nguygn dumg i, j, t , cy (ty, c~ 5 lo4)
ma tA d i g nbi tqrc tikp tir net i d&n nfit j, thbi gian vh chi phi ding luqng t m g img
Hai d lign ti&$ tr2n mot dbng file dB lieu c h h it nhbt mat dku c k h
d t quik: Ghi la file vHn bh ROBOT.OUT mot s6 nguyen ducmg w tlm duqc Vi dy:
Ghi chu:
Thi sinh @6ng duqc s u dung t6i li@u
Cdn bb &i thi Mdng gidi thich gi them
ROBOT,INP 4
0 1 5
1 1 1 2 4 3
Trang 313
ROBOT OUT