Competencias Program Ac i on Inter Colegiales
-
Upload
jonathan-vargas-rodriguez -
Category
Documents
-
view
224 -
download
0
Transcript of Competencias Program Ac i on Inter Colegiales
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 1/499
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 2/499
AGRADECIMIENTOS
2
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 3/499
INTRODUCCIÓN
3
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 4/499
TABLA DE CONTENIDOUniversidad de Puerto Rico en Bayamón
Input .................................................................................................................................................................................Output !"#$$n%..............................................................................................................................................................S&'p($'$nt$ )* * '+!t#*# $n p*nt*((* (+! #$!u(t*,+! $n"+nt#*,+! - )* * n+t& &"*# (* "*nt&,*, ,$ n/'$#+! $n"+nt#C+##&,* ,$ $0$'p(+ ........................................................................................................................................................Input !"#$$n%.................................................................................................................................................................Output !"#$$n &($ )*'p&#+.+ut%..............................................................................................................................C+##&,* ,$ $0$'p(+ ........................................................................................................................................................P*#* !&'p(& &"*# un p+"+ $( p#+5($'*6 !$ )* * &n,&"*# (* p+!&"&7n &n&"&*( $n ,+n,$ !$ )* * "+'$n8*# $(n/'$#+ &n&"&*( '*-+#% - $( t*'*9+ ,$( t*5($#+ )* * !$# &0+ : ; :%.......................................................................Input &($ !*5u$!+.&n%................................................................................................................................................Output &($ !*5u$!+.+ut%.............................................................................................................................................SOLON F&($ S-!t$' = A(( F&($ S&8$.........................................................................................................................
D$ &n&"&7n ,$( p#+5($'*.........................................................................................................................................FC.............................................................................................................................................................................................In>(&n?....................................................................................................................................................................................
E( p#+@#*'*................................................................................................................................................................IMPORTANTE ...............................................................................................................................................................2
Input ................................................................................................................................................................................Output ..............................................................................................................................................................................S*'p($ Input F&($ 5+'5*!.&n%....................................................................................................................................S*'p($ Output F&($ 5+'5*!.+ut%..................................................................................................................................Input .................................................................................................................................................................................Output ..............................................................................................................................................................................S*'p($ Input F&($ ?(&n@+n.&n%..............................................................................................................................S*'p($ Output ?(&n@+n.+ut%......................................................................................................................................SOLON F&($ S-!t$' D$ #*@'$nt*t+# 1.<.....................................................................................................................
D$ &n&"&7n ,$( p#+5($'*.........................................................................................................................................FC.............................................................................................................................................................................................In>(&n?....................................................................................................................................................................................
E( p#+@#*'*................................................................................................................................................................IMPORTANTE ...............................................................................................................................................................2
S*'p($ Input Output +# S*'p($ Input.....................................................................................................Input ................................................................................................................................................................................Output .............................................................................................................................................................................S*'p($ Input ....................................................................................................................................................................S*'p($ Output .................................................................................................................................................................Input .................................................................................................................................................................................Output ..............................................................................................................................................................................S*'p($ Input F&($ '&n$! $$p$#.&n%..........................................................................................................................S*'p($ Output F&($ '&n$! $$p$#.+ut%.......................................................................................................................Input .................................................................................................................................................................................Output ..............................................................................................................................................................................S*'p($ Input S"#$$n%....................................................................................................................................................S*'p($ Output S"#$$n%.................................................................................................................................................
Input .................................................................................................................................................................................Output ..............................................................................................................................................................................S*'p($ Output...................................................................................................................................................................F&($ LC,&!p(*-.+ut%..................................................................................................................................................S*'p($ Input .....................................................................................................................................................................F&($ LC,&!p(*-.&n%...................................................................................................................................................Input .................................................................................................................................................................................Output ..............................................................................................................................................................................S*'p($ Input F&($ p#&'*#-.&n%..................................................................................................................................S*'p($ Output F&($ p#&'*#-.+ut%..............................................................................................................................Input .................................................................................................................................................................................Output ..............................................................................................................................................................................
4
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 5/499
S*'p($ Input F&($ #$)$#!$.&n%..................................................................................................................................S*'p($ Output F&($ #$)$#!$.+ut%...............................................................................................................................Input .................................................................................................................................................................................Output ..............................................................................................................................................................................S*'p($ Input F&($ *(,+# .&n%....................................................................................................................................S*'p($ Output F&($ *(,+# .+ut%.................................................................................................................................Input .................................................................................................................................................................................Output ..............................................................................................................................................................................S*'p($ Input F&($ +u#p#&'$!.&n%............................................................................................................................S*'p($ Output F&($ +u#p#&'$!.+ut%.........................................................................................................................Input .................................................................................................................................................................................Output ..............................................................................................................................................................................S*'p($ Input F&($ *nt.&n%..........................................................................................................................................S*'p($ Output F&($ *nt.+ut%.......................................................................................................................................S*'p($ Input F&($ 't.&n%............................................................................................................................................S*'p($ Output F&($ 't.+ut%.........................................................................................................................................
..................................................................................................................................................................................................Input..................................................................................................................................................................................Output...............................................................................................................................................................................S*'p($ &nput F&($ "*("u(*t+#.&n%...........................................................................................................................S*'p($ +utput F&($ "*("u(*t+#.+ut%...........................................................................................................................Input .................................................................................................................................................................................Output ..............................................................................................................................................................................S*'p($ Input F&($ " $"?.&n%.......................................................................................................................................S*'p($ Output F&($ " $"?.+ut%....................................................................................................................................Input .................................................................................................................................................................................Output ..............................................................................................................................................................................S*'p($ Input F&($ ! (.&n%...........................................................................................................................................S*'p($ Output S"#$$n%................................................................................................................................................
I'p+#t*,+# ,$ ,*t+! ,$!,$ COBOL *(............................................................................................................................S+(+n D*t*5*!$ M*n*@$'$nt S-!t$' SDBMS%.......................................................................................................
S*'p($ Input F&($ SDBMS>IN.T;T%..........................................................................................................................S*'p($ Output F&($ SDBMS>OUT.T;T%..................................................................................................................
u&nt*! C+'p$t$n"&*! ,$ P#+@#*'*"&7n 2<<4..............................................................................................................E p$#t+.................................................................................................................................................................................
ENCAHAR......................................................................................................................................................................M+#!$ M&!'*t" $!.......................................................................................................................................................L>FAT DEFRAG. E;E................................................................................................................................................D&)$#!&7n C+n G#* +!.............................................................................................................................................
u&nt*! C+'p$t$n"&*! ,$ P#+@#*'*"&7n 2<<4..............................................................................................................Int$#'$,&+............................................................................................................................................................................
PARENT..........................................................................................................................................................................Sp#$*,! $$t C*("u(*t+#...............................................................................................................................................ESCALERA ARITM TICA........................................................................................................................................ NUMBER PROPERTIES...........................................................................................................................................
Cu*#t*! C+'p$t$n"&*! ,$ P#+@#*'*"&7n 2<<3..............................................................................................................E p$#t+ ............................................................................................................................................................................
A R$*( Pu88($#...........................................................................................................................................................
G+.....................................................................................................................................................................................3D T&">T*">T+$.......................................................................................................................................................T#$*!u#$ I!(*n,...........................................................................................................................................................
Cu*#t*! C+'p$t$n"&*! ,$ P#+@#*'*"&7n 2<<3..............................................................................................................Int$#'$,&+ .......................................................................................................................................................................
ESTRELLAS................................................................................................................................................................Sup$# F#$ ...................................................................................................................................................................P+!t2In..........................................................................................................................................................................B+t" *@*(++p.............................................................................................................................................................
Cu*#t*! C+'p$t$n"&*! ,$ P#+@#*'*"&7n 2<<3..............................................................................................................P#&n"&p&*nt$...............................................................................................................................................................
CONHETURA DE ULLMAN...................................................................................................................................
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 6/499
JISTOGRAMA DE PALABRAS...............................................................................................................................C*5#*""&.....................................................................................................................................................................B*(*n"$, P*#$nt $!$!..................................................................................................................................................
T$#"$#*! C+'p$t$n"&*! ,$ P#+@#*'*"&7n 2<<2...........................................................................................................P#&n"&p&*nt$ ..............................................................................................................................................................
C+''+n L$tt$#!.............................................................................................................................................................1St#&n@ C+'p#$!!&+n................................................................................................................................................DECIMAL COMPLEMENTS....................................................................................................................................BANNER NUMERICO..............................................................................................................................................
T$#"$#*! C+'p$t$n"&*! ,$ P#+@#*'*"&7n 2<<2...........................................................................................................Int$#'$,&+..........................................................................................................................................................................1
KELL ORDERED NUMBERS..................................................................................................................................JORI ONTAL JISTOGRAM.....................................................................................................................................1SJUTTLE PU LE......................................................................................................................................................1 NUMBER FANTASIES..............................................................................................................................................
T$#"$#*! C+'p$t$n"&*! ,$ P#+@#*'*"&7n 2<<2...........................................................................................................E p$#t+...............................................................................................................................................................................1
: : CJEC ER CJALLENGER.................................................................................................................................. 11 NÚMERO OCULTO...................................................................................................................................................MULTIPLICACIÓN POR EL M TODO DE LA REHILLA...................................................................................JTML CODE OPTIMI ER..........................................................................................................................................
P#&'$#*! C+'p$t$n"&*! ,$ P#+@#*'*"&7n 2<<<...........................................................................................................E p$#t+ ............................................................................................................................................................................
PIR MIDES NUM RICAS.........................................................................................................................................LA AMENA A.............................................................................................................................................................
DNS C*" $ ........................................................................................................................................................................A,,#$!! R$!+(ut&+n S&'u(*t&+n...............................................................................................................................P#+5($'* 3 E( $($ *nt$ Fu#&+!+..............................................................................................................................D*t*5*!$ L+@@&n@ T*5($!...................................................................................................................................Su5!$t!..........................................................................................................................................................................K+#, Pu88($ ............................................................................................................................................................. 1
C+'p$t$n"&*! ,$ P#+@#*'*"&7n 1 .................................................................................................................................E p$#t+...............................................................................................................................................................................1
T$##*n )!. $#@!.................................................................................................................................................................T$##*n M$!!*@$ D$"-p $#........................................................................................................................................SUPERPRIME RIB.....................................................................................................................................................
NUMBER TRIANGLES............................................................................................................................................ERO SUM...................................................................................................................................................................FRIDAY TJE 13TJ......................................................................................................................................................
C+'p$t$n"&*! ,$ P#+@#*'*"&7n 1 .................................................................................................................................Int$#'$,&+..........................................................................................................................................................................1
PROGRAM LISTING.................................................................................................................................................T$($p +n$ D&#$"t+#- S$*#" ....................................................................................................................................Sup$# R+'*n Nu'$#*(! Q +(!t*,6 1 .......................................................................................................................14FACTORIALS.............................................................................................................................................................PRIME PALINDROMES............................................................................................................................................
C+'p$t$n"&*! ,$ P#+@#*'*"&7n 1 .................................................................................................................................P#&n"&p&*nt$...............................................................................................................................................................
V*(&,*"&7n ,$ T*#0$t*! ,$ C# ,&t+.........................................................................................................................
C LCULO DE FECJAS..............................................................................................................................................CONVERSION DE NUMEROS JE;ADECIMALES..............................................................................................Y2 S+ t *#$ S+(ut&+n.......................................................................................................................................................
D*t$ K&n,+ &n@.......................................................................................................................................................PROGRAM LISTING.................................................................................................................................................
C+'p$t$n"&*! ,$ P#+@#*'*"&7n 1 .................................................................................................................................E p$#t+...............................................................................................................................................................................1
C+,$ G$n$#*t&+n.......................................................................................................................................................CONVERSION..............................................................................................................................................................1P*!"*( t+ A!!$'5($# C+n)$#t$#...................................................................................................................................
C+'p$t$n"&*! ,$ P#+@#*'*"&7n 1 .................................................................................................................................E p$#t+ ............................................................................................................................................................................
:
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 7/499
BINARY CALCULATOR..........................................................................................................................................D&#$"t+#- L&!t&n@ C+''*n, S&'u(*t+#..................................................................................................................P#+5($' 3 GOLDBACJ CONHECTURE.................................................................................................................LONG6 LONG DIVISION.........................................................................................................................................
C+'p$t$n"&*! ,$ P#+@#*'*"&7n 1 .................................................................................................................................Int$#'$,&+..........................................................................................................................................................................1
DEALING A DEC OF CARDS................................................................................................................................FRACTIONS TO DECIMALS..................................................................................................................................EIGJT UEEN KITJ A TKIST................................................................................................................................ 1PU LE ........................................................................................................................................................................1
C+'p$t$n"&*! ,$ P#+@#*'*"&7n 1 .................................................................................................................................P#&n"&p&*nt$!..................................................................................................................................................................
E;PONENTIATION.....................................................................................................................................................1DEALING A DEC OF CARDS................................................................................................................................SUBTRACTING BIG NUMBERS............................................................................................................................FACE OF TJE CLOC ................................................................................................................................................1PROBLEMAS PARA ELIMINATORIAS................................................................................................................
C+'p$t$n"&*! ,$ P#+@#*'*"&7n 1 :................................................................................................................................E p$#t+...............................................................................................................................................................................1 .........................................................................................................................................................................................CUTB P#+@#*''&n@ C+nt$!t.......................................................................................................................................
CABRA COMPILER..................................................................................................................................................C+'p$t$n"&*! ,$ P#+@#*'*"&7n 1 :................................................................................................................................
P#&n"&p&*nt$! ............................................................................................................................................................MORSE CODE............................................................................................................................................................MASTERMIND.............................................................................................................................................................1TE;T COUNT...............................................................................................................................................................MEASUREMENT AND UNIT CONVERSION......................................................................................................
ICOM C *(($n@$ 2<<<.....................................................................................................................................................E p$#t D&)&!&+n...........................................................................................................................................................
V*#&*5($ R*,& Ju '*n En"+,&n@..........................................................................................................................M$t*>L++p($!! S+#t!.................................................................................................................................................u*,t#$$!.......................................................................................................................................................................
ICOM C *(($n@$ 2<<<.....................................................................................................................................................Int$#'$,&*t$ D&)&!&+n................................................................................................................................................
P*"?$t!..........................................................................................................................................................................
T$($p +n$ T*n@($!....................................................................................................................................................V*#&*5($ R*,& Ju '*n En"+,&n@..........................................................................................................................ICOM C *(($n@$ 2<<<.....................................................................................................................................................
B$@&nn$# D&)&!&+n.................................................................................................................................................M*!t$#>M&n, J&nt!...................................................................................................................................................R$"+@n&8&n@ G++, ISBN!...................................................................................................................................P*"?$t!..........................................................................................................................................................................
ICOM C *(($n@$ ............................................................................................................................................................E p$#t D&)&!&+n...........................................................................................................................................................
A $!+'$ D$"&'*(!....................................................................................................................................................... 2T+ C*" $ +# n+t t+ C*" $ . . .......................................................................................................................................O5!t*"($!........................................................................................................................................................................2A S&'p($ Int$#p#$t$#.................................................................................................................................................
St#+n@(- C+nn$"t$, C+'p+n$nt!...............................................................................................................................ICOM C *(($n@$ ........................................................................................................................................................Int$#'$,&*t$ D&)&!&+n................................................................................................................................................
D*t*5*!$ L+@@&n@ T*5($!...................................................................................................................................Su5!$t!..........................................................................................................................................................................
K+#, Pu88($ .....................................................................................................................................................................Pu88($ D$!"#&pt&+n.................................................................................................................................................T$($p +n$ D&#$"t+#- S$*#" ....................................................................................................................................
ICOM C *(($n@$ ............................................................................................................................................................B$@&nn$# D&)&!&+n.................................................................................................................................................
P*#&t- C $"?&n@.......................................................................................................................................................;M+#!$..........................................................................................................................................................................
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 8/499
Y2 P#+5($'.................................................................................................................................................................2T $ B*#t C *(($n@$....................................................................................................................................................K+#, Pu88($.................................................................................................................................................................
ICOM C *(($n@$ ............................................................................................................................................................E p$#t D&)&!&+n...........................................................................................................................................................
C+,$ G$n$#*t+#..........................................................................................................................................................n&@ t T+u#................................................................................................................................................................DNA T#*n!(*t&+n......................................................................................................................................................T $ Et#u!"*n C*("u(*t+#.............................................................................................................................................
S+u#"$ F&($ )&!&+n.Q"p ..............................................................................................................................................C-5$#)&!&+n...................................................................................................................................................................
ICOM C *(($n@$ ............................................................................................................................................................Int$#'$,&*t$ D&)&!&+n................................................................................................................................................
E@-pt&*n Mu(t&p(&"*t&+n....................................................................................................................................u$$n T+u#...................................................................................................................................................................On t $ S&,$ *(?............................................................................................................................................................
S*'p($ Input.........................................................................................................................................................................S*'p($ Output.......................................................................................................................................................................
H+ n C+n *- ! G*'$ + L& $........................................................................................................................................G$n$#*t&+n <....................................................................................................................................................................
G*(*"t&" I'p+#t...........................................................................................................................................................ICOM C *(($n@$ ............................................................................................................................................................
B$@&nn$# D&)&!&+n.................................................................................................................................................C+'5&n*t&+n!.............................................................................................................................................................M*-* C*($n,*#............................................................................................................................................................
N+t&"$ t *t $*" ,*- *! *n *'5& ,$!"#&pt&+n. F+# $ *'p($6 *t t $ 5$@&nn&n@ ...................................................J**5 O. p+p <.............................................................................................................................................................
P*(&n,#+'$ D$t$"t&+n U!&n@ R$"u#!&+n............................................................................................................ICOM C *(($n@$ ............................................................................................................................................................
B$@&nn$# D&)&!&+n.................................................................................................................................................C+'p#$!!&+n................................................................................................................................................................
ICOM C *(($n@$ ............................................................................................................................................................E p$#t D&)&!&+n...........................................................................................................................................................
P#+5($' JTML T*5($!.................................................................................................................................................P#+5($' N*)&@*t&+n + * S&'p($ M*8$................................................................................................................TJE AMA ING MA E PROGRAM...........................................................................................................................2
ICOM C *(($n@$ ............................................................................................................................................................Int$#'$,&*t$ D&)&!&+n................................................................................................................................................P#+5($' K+#, M+#p &n@..........................................................................................................................................P#+5($' C#-pt*#&t '$t&"............................................................................................................................................P#+5($' N*)&@*t&+n + * S&'p($ M*8$................................................................................................................TJE AMA ING MA E PROGRAM...........................................................................................................................3P#+5($' D*t$t&'$........................................................................................................................................................P#+5($' M*@&" Nu'5$#...........................................................................................................................................P#+5($' A T*(? P*"?$t Sn& $#...............................................................................................................................P#+5($' D&"t&+n*#-.................................................................................................................................................
ICOM C *(($n@$ ............................................................................................................................................................E p$#t D&)&!&+n...........................................................................................................................................................
P#+5($'1. D*t$t&'$......................................................................................................................................................
Input.......................................................................................................................................................................................3 P#+5($' 2. C #&!t'*! T#$$........................................................................................................................................P*!"*( t+ C M&n&>K &($> C+n)$#t$#....................................................................................................................
Input F&($ N*'$ AD3.P*!............................................................................................................................................R$!t*u#*nt D*t*5*!$..................................................................................................................................................
ICOM C *(($n@$ ............................................................................................................................................................Int$#'$,&*t$ D&)&!&+n................................................................................................................................................
P#+5($' 1. G#$*t$!t C+''+n D&)&!+#......................................................................................................................S+u#"$ F&($ n*'$ ID1. ...................................................................................................................................................
P#+5($' 2. M$*!u#$'$nt *n, Un&t C+n)$#!&+n......................................................................................................S+u#"$ F&($ N*'$ ID2. ..................................................................................................................................................
P#+5($' 3. St*"? M*n&pu(*t&+n.............................................................................................................................
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 9/499
S+u#"$ &($ n*'$ ID3. .....................................................................................................................................................P#+5($' 4. B&n*#- t+ ,$"&'*(6 +"t*( *n, $ "+n)$#!&+n .....................................................................................P#+5($' 1 P#$)&+u! D*t$..........................................................................................................................................P#+5($' 2. D&!t*n"$6 M&,p+&nt *n, S(+p$............................................................................................................P#+5($' 3. C *n@$..................................................................................................................................................... P#+5($' 4. T$ t E,&t&n@......................................................................................................................................
ICOM C *(($n@$ 4...........................................................................................................................................................E p$#t D&)&!&+n...........................................................................................................................................................
P#+5($' I. M$'+#- M*n*@$'$nt..................................................................................................................................Tu#t($ T$ t G#*p &"!..................................................................................................................................................P#+5($' 4. Ju '*n C+,&n@.........................................................................................................................................
S+u#"$ F&($ N*'$ A D 4. ; ; ;..........................................................................................................................................3P#+5($' . L*#@$ Nu'5$#!..........................................................................................................................................
ICOM C *(($n@$ 4...........................................................................................................................................................Int$#'$,&*t$ D&)&!&+n................................................................................................................................................
P#+5($'1. STAC MANIPULATION........................................................................................................................P#+5($' 2. EASY CALENDAR .................................................................................................................................EIGJT UEENS KITJ A TKIST.............................................................................................................................. 34
COMPETENCIAS DE PROGRAMACIÓN 1 1.............................................................................................................S+u#"$ F&($ N*'$ PRIN1. ............................................................................................................................................
PROBLEMA 1...............................................................................................................................................................ARCJIVO DE CODIGO PRIN1. .........................................................................................................................3ARCJIVO DE CODIGO PRIN2. .........................................................................................................................3
NW X 1 2 3 N.......................................................................................................................................................3S+u#"$ F&($ N*'$ PRIN3. .............................................................................................................................................
Fun"&7n ,$ A"?$#'*n..................................................................................................................................................................................................................................................................................................................................................34............................................................................................................................................................................................34............................................................................................................................................................................................34
ARCJIVO DE CODIGO PRIN4. ..........................................................................................................................3ARCJIVO DE CODIGO PRIN . 6 ....................................................................................................................... 3
COMPETENCIAS DE PROGRAMACIÓN 1 1.............................................................................................................E p$#t+...............................................................................................................................................................................3
LONG6 LONG DIVISION.........................................................................................................................................P#+5($' 1.....................................................................................................................................................................
ENTER FIRST NUMBERZ .........................................................................................................................................
D&)&,$n, &! .................................................................................................................................................................TJE DATABASE PROBLEM............................................................................................................................................P#+5($' 3 GOLDBACJ CONHECTURE.................................................................................................................CALCULATOR.............................................................................................................................................................3P#+5($' 1 = P*t F&n,$#..............................................................................................................................................
Input F&($ N*'$ ED1.DAT................................................................................................................................................Output F&($ N*'$ ED1.Out ..............................................................................................................................................
P#+5($' 2 = T $ Yu"* C+'p(&$#................................................................................................................................. Input F&($ N*'$ ED2.DAT........................................................................................................................................... Output F&($ N*'$ ED2.Out.........................................................................................................................................
P#+5($' 3 = M+)&$ L&!t&n@! D*t*5*!$................................................................................................................P#+5($' 4 = D&#$"t+#- S$*#" ...................................................................................................................................P#+5($' > Pu88($........................................................................................................................................................
P#+5($' :> T $ [P-#*'&,\ S+#t.....................................................................................................................................COMPETENCIAS DE PROGRAMACIÓN 2<<4...........................................................................................................E p$#t+!............................................................................................................................................................................
D$"&'*(>B&n*#-............................................................................................................................................................T&'$ C*#,.....................................................................................................................................................................Mu(t&p(&"*"&7n Ru!*..............................................................................................................................................V$#t&"*( J&!t+@#*'..................................................................................................................................................
COMPETENCIAS DE PROGRAMACIÓN 2<<4...........................................................................................................P#&n"&p&*nt$! ............................................................................................................................................................Un&)$#!&,*, Int$#*'$#&"*n* ,$ Pu$#t+ R&"+...........................................................................................................
C*! R$@&!t$# App(&"*t&+n% .............................................................................................................................P#$!$nt V*(u$ C*("u(*t+# App(&"*t&+n% ..........................................................................................................
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 10/499
A##*-%............................................................................................................................................................................C#$*t$ *n, M*&nt*&n T$($p +n$ D&#$"t+#&$!%...............................................................................................
COMPETENCIAS DE PROGRAMACIÓN 2<<3...........................................................................................................E p$#t+! ...........................................................................................................................................................................Int$#B*-..............................................................................................................................................................................4
K$&@ t$, B&n*#- T#$$!...........................................................................................................................................T#&*n@($.......................................................................................................................................................................An+t $# B*(*n"&n@ A"t............................................................................................................................................ACSL8&p....................................................................................................................................................................
COMPETENCIAS DE PROGRAMACIÓN 2<<3...........................................................................................................P#&n"&p&*nt$!..................................................................................................................................................................
COUNTCJARS...........................................................................................................................................................D$"+,&n@ *n En"+,$, T$ t &($.................................................................................................................................V&#u! D$t$"t&+n....................................................................................................................................................... Nu'5$# P#+p$#t&$!.....................................................................................................................................................T&'$ C*#,.....................................................................................................................................................................
COMPETENCIAS DE PROGRAMACIÓN 2<<2...........................................................................................................E p$#t+!............................................................................................................................................................................
Mu(t&p(&"*"&7n Ru!*..............................................................................................................................................V$#t&"*( J&!t+@#*'..................................................................................................................................................
COMPETENCIAS DE PROGRAMACIÓN 2<<2...........................................................................................................Int$#'$,&+! ......................................................................................................................................................................
T $ In 5$t $$n Su'...................................................................................................................................................... 4P#&nt * St#&n@ B*"? *#,% ....................................................................................................................................
COMPETENCIAS DE PROGRAMACIÓN 2<<2...........................................................................................................P#&n"&p&*nt$! ............................................................................................................................................................
R+t*t&n@ K+#,!.........................................................................................................................................................COMPETENCIAS DE PROGRAMACIÓN 2<<1...........................................................................................................
E p$#t+! ...........................................................................................................................................................................PROBLEMA 1............................................................................................................................................................PROBLEMA 3............................................................................................................................................................
COMPETENCIAS DE PROGRAMACIÓN 2<<1...........................................................................................................Int$#'$,&+! ......................................................................................................................................................................
P#+@#*'* P(*n&((* +#'* "+#t*. ..............................................................................................................................PROBLEMA 2............................................................................................................................................................PROBLEMA 3............................................................................................................................................................
P#+@#*'* P#+'$,&+!. ...............................................................................................................................................COMPETENCIAS DE PROGRAMACIÓN 2<<1...........................................................................................................P#&n"&p&*nt$! ............................................................................................................................................................
P#+@#*'* ,$ n/'$#+!....................................................................................................................................................P#+@#*'* p*#* !+#t$*# p+# $,*,..............................................................................................................................P#+@#*'* p*#* "*("u(*# "u$nt*! * "+5#*#..............................................................................................................P#+@#*'* p*#* #$"&5+ ,$ )$nt*...............................................................................................................................
COMPETENCIAS DE PROGRAMACIÓN 2<<1...........................................................................................................P#$'&*"&+n$! ...............................................................................................................................................................
CATEGORY ADVANCED......................................................................................................................................CATEGORY INTERMEDIATE...............................................................................................................................CATEGORY BEGINNERS.......................................................................................................................................
COMPETENCIAS DE PROGRAMACIÓN 2<<<..........................................................................................................
E p$#t+! ...........................................................................................................................................................................COMPETENCIAS DE PROGRAMACIÓN 2<<<..........................................................................................................Int$#'$,&+! ......................................................................................................................................................................
PROBLEMA 1............................................................................................................................................................PROBLEMA 2............................................................................................................................................................PROBLEMA 3............................................................................................................................................................
COMPETENCIAS DE PROGRAMACIÓN 2<<<..........................................................................................................P#&n"&p&*nt$! ............................................................................................................................................................Un&)$#!&,*, Int$#*'$#&"*n* ,$ Pu$#t+ R&"+...........................................................................................................
PROBLEMA 1............................................................................................................................................................PROBLEMA 2............................................................................................................................................................PROBLEMA 3............................................................................................................................................................
1<
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 11/499
PROBLEMA 4............................................................................................................................................................COBOL DESCRIPTION GENERATOR..................................................................................................................
DESCRIPCION DEL REPORTE......................................................................................................................................COBOL DESCRIPTION OPTIMI ER.......................................................................................................................
DESCRIPCION OPTIMI ADA.........................................................................................................................................TCAL . <1 C+'p&($#TCAL N$!t$, L++p t+ < : A!!$'5(- L*n@u*@$.................................................................
S*(&,* TCAL.OUT%........................................................................................................................................................PROBLEM 1. CAPS.................................................................................................................................................PROBLEM 2. CJARACTER TO ASCCII TO CJARACTER AGAIN...............................................................PROBLEM 3. PJONE CODE..................................................................................................................................PROBLEM 4. DAY OF TJE KEE ........................................................................................................................4PROBLEM . TE;T INVERTER.............................................................................................................................4PROBLEMA 1............................................................................................................................................................PROBLEMA 2............................................................................................................................................................PROBLEMA 3...........................................................................................................................................................PROBLEMA 4............................................................................................................................................................FOGUEO DE PROGRAMACIÓN............................................................................................................................DIRECTORY LISTING COMMAND SIMULATOR..............................................................................................FOGUEO DE PROGRAMACIÓN............................................................................................................................TECO EDITOR .........................................................................................................................................................P#+5($' 1 ] J+t$( R$!$#)*t&+n...................................................................................................................................P#+5($' 2 P(+t Fun"t&+n!..........................................................................................................................................P#+5($' 3 ] F*"t+#&*(!...............................................................................................................................................P#+5($' 4 E u*( t+ $#+..............................................................................................................................................P#+5($' 1 D&!t*n"$6 M&,p+&nt *n, S(+p$............................................................................................................P#+5($' 2 D#* S *p$!................................................................................................................................................4P#+5($' 3 F&($ M*n*@$'$nt....................................................................................................................................P#+5($' 4 A#,$! L*5$(!..............................................................................................................................................PROGRAMA DECODIFICACIÓN DOBLE...........................................................................................................J&@ S" ++( C *(($n@$ 1 .......................................................................................................................................
E(&'&n*t+#&* CUTB 4...................................................................................................................................................P#+5($'* 1 R$!t* ,$ N/'$#+! G#*n,$!..................................................................................................................... 4
E(&'&n*t+#&* CUTB 4...................................................................................................................................................P#+5($'* 2 C*'&n+ ,$( C*5*((+...............................................................................................................................
E(&'&n*t+#&* CUTB 4................................................................................................................................................... p#+@#*'* p#+@3. ..........................................................................................................................................................
P#+5($'* 3 E( $($ *nt$ Fu#&+!+..............................................................................................................................E!"#&5* un p#+@#*'* u$ p&,* ,$( u!u*#&+ un n+'5#$ ,$ un $'p($*,+6 - un t+t*( ,$ +#*! t#*5*0*,*! - ,*,* $!t*&n +#'*"&7n *@* (+! "*("u(+! "+##$!p+n,&$nt$! $ &'p#&'* (* !&@u&$nt$ &n +#'*"&7n ............................... N+t* P*@* p+# +#*6 *!t* 4< +#*! ^:.<<..............................................................................................................E!"#&5* un p#+@#*'* u$ !u'$ ,+! n/'$#+! 5&n*#&+!6 "+n un '_ &'+ ,$ +" + % ,`@&t+! p+# n/'$#+!. R$"u$#$n 5&n*#&+! 1 1X< - !$ [(($)* 1\a 1 <X1a - 1 1 1X1 - !$ [(($)* 1\............................................................................ N+t* (* p$(+t&t* n+ pu$,$ !*(&# ,$( '*#@$n ,$ (* p*nt*((*6 - (* '&!'* ,$5$ (($@*# (+ '_! "$#"*n+ *( 5+#,$ p+
11
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 12/499
UNIVERSIDAD DE PUERTO RICO
EN BAYAMÓN
12
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 13/499
Fecha 22b*5#&(b2<<: Nombre de la competencia S pt&'*!C+'p$t$n"&*!Categoría P#&n"&p&*nt$! Universidad UPR = B*-*'7nAutor N$((&u, D. T+##$! Tipo de competencia P#+@#*'*"&7nProblema 1
!A PA!ABRA CRU"A#A
D$!*##+(($ un p#+@#*'* u$ p&,* p+# p*nt*((* un* p*(*5#* ,$ t#$! 3% *13 "*#*"t$#$!. C+n $!* p*(*5#* ! $ )* * +#'*# un* ; $n ,+n,$ $("*#*"t$# ,$( '$,&+ !$ #$p&t$ un* !+(* )$8. E( p#+@#*'* ,$5$ )*(&,*#u$ (* "*nt&,*, ,$ "*#*"t$#$! $nt#*,+! !$* &'p*# - u$ n+ !$* '$n+# ,$3 "*#*"t$#$! n& '*-+# ,$ 13. S& )* * $!"#&5&# $( p#+@#*'* $n un($n@u*0$ ,$ +#&$nt*"&7n @#_ &"* "+'+ V&!u*( B*!&"6 *!$@/#$!$ ,$ p+n$#$( t&p+ ,$ ($t#* $n (* !*(&,* "+'+Courier New .
$%emplo &
Entre una palabra impar de 3 a 13 caracteres: elPalabra menor de 3 caracteres, trate de nuevo
Entre una palabra impar de 3 a 13 caracteres: amorPalabra par, trate de nuevo
Entre una palabra impar de 3 a 12 caracteres: parangutirimicuaroPalabra mayor de 13 caracteres, trate de nuevo
Entre una palabra impar de 3 a 13 caracteres: linux
l l i i n u ux x
$%emplo '(
Entre una palabra de 3 a 12 caracteres: Microsoft
M M
i i c c r r o s s o o f ft t
13
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 14/499
Fecha 22b*5#&(b2<<: Nombre de la competencia S pt&'*!C+'p$t$n"&*!Categoría P#&n"&p&*nt$! Universidad UPR = B*-*'7nAutor N$((&u, D. T+##$! Tipo de competencia P#+@#*'*"&7nProblema 2
N)meros Pseudopar*sitos
L+! n/'$#+! p*#_!&t+! !$@/n $( D#. G++@+(% !+n * u$((+! n/'$#+! u$ *('u(t&p(&"*#!$ p+# un n/'$#+ ,$ un ,`@&t+6 "*'5&* $( ,`@&t+ ,$ (* /(t&'* p+!&"&7n *(* p#&'$#*. En +t#*! p*(*5#*! $( 'u(t&p(&"*n,+ $! !&'&(*# *( #$!u(t*,+ $ "$pt+ u$$( /(t&'+ ,`@&t+ $! $( p#&'$#+ ,$( #$!u(t*,+. E( !&@u&$nt$ $0$'p(+ !$ $ p(&"* p+# !&!+(+ 1<26 :+ ; + X +1<62 :. P*#* u$ !$* un )$#,*,$#+ n/'$#+ p*#_!&t+ $('u(t&p(&"*,+# ,$5$ !$# !&'&(*# *( n/'$#+ u$ "*'5&* ,$ p+!&"&7n $n $( #$!u(t*,+.L*'$nt*5($'$nt$ !+n 'u- $!"*!+! $!t+! n/'$#+!. Un* )*#&*"&7n !+n (+! p!$u,+p*#_!&t+! u$ *( 'u(t&p(&"*#!$ p+# 4 "*'5&*n $( /(t&'+ ,`@&t+ *( p#&n"&p&+6 p$#+ $!t$ n+ $! !&'&(*# *( 'u(t&p(&"*,+#. Un $0$'p(+ $! 1 36 4, ; 4 X , 1 63 4. Aun u$ $!t+! +t#+n/'$#+! !+n t*'5& n #*#+!6 +"u##$n "+n '_! #$"u$n"&* u$ (+! n/'$#+! p*#_!&t+! $!p$""u*n,+ $( 'u(t&p(&"*,+# $! 4. E!"#&5* un p#+@#*'* u$ 5u! u$ * u$((+! n/'$#+! p*#_!&t+! ,1<<6<<< = 6 % u$ *( 'u(t&p(&"*#!$ p+# 4 "*'5&$ $( /(t&'+ ,`@&t+ ,$ (u@*#.
Input
E( p#+@#*'* n+ )* * p$,&# *5!+(ut*'$nt$ n*,* *( u!u*#&+. .
Output (screen)
Simplemente va a mostrar en pantalla los resultados encontrados y va a notificar la cantidadde números encontrados.
Corrida de ejemplo
12 ,2!" # $ % "12, 2!
&
&'otal de n(meros pseudopar)sitos de * d+ itos-.$/: 99
14
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 15/499
Fecha 22b*5#&(b2<<: Nombre de la competencia S pt&'*!C+'p$t$n"&*!Categoría P#&n"&p&*nt$! Universidad UPR = B*-*'7nAutor Ant+n&+ Ju$#t*! Tipo de competencia P#+@#*'*"&7nProblema ( 3
-. /$R0.1N #$ TA.!
E( !&!t$'* +p$#*t&)+ UNI; p#+)$$ un "+'*n,+ ((*'*,+tail u$ 'u$!t#* (*! /(t&'*! n (`n$*! ,$ un*#" &)+ ,$ t$ t+. E!"#&5* un p#+@#*'* u$ p#$@unt$ $( n+'5#$ ,$ un *#" &)+ ,$ t$ t+ - unu$ !$ "+'p+#t$ "+'+ tail. S& $( *#" &)+ t&$n$ '$n+! ,$n (`n$*!6 $( p#+@#*'* ,$5$ '+!t#*#todo $("+nt$n&,+ ,$( *#" &)+. A!u'* u$ "*,* (`n$* ,$( *#" &)+ *"*5* $n cnd. V*(&,$ u$ $( *#" &u$ $( )*(+# ,$n !$* < 7 '_!.
Archivo de Prueba 23ernel4t5t6(0ue es el ernel
El ernel o n(cleo del sistema operativo es el pro rama ue se comunicadirectamente con el 4ardware& Esta es la parte del sistema operativo uese car a en 56M cuando se enciende la computadora y permanece en 56M 4astaue la computadora se apa a& Est) escrito, en el caso de 7nix, mayormenteen C con un poco de len ua8e de ensambla8e& El ernel debe interactuar conlos usuarios, con los pro ramas y, obviamente, con el 4ardware&
$%emplo(9ndi ue el nombre del arc4ivo: abc.txtEl arc4ivo no existe, trate de nuevo&
9ndi ue el nombre del arc4ivo: kernel.txt
9ndi ue la cantidad de l+neas:-10
a cantidad de l+neas es menor de !, trate de nuevo&
9ndi ue la cantidad de l+neas: 4
as (ltimas $ l+neas de ernel&txt son:
se car a en 56M cuando se enciende la computadora y permanece en 56M 4astaue la computadora se apa a& Est) escrito, en el caso de 7nix, mayormenteen C con un poco de len ua8e de ensambla8e& El ernel debe interactuar conlos usuarios, con los pro ramas y, obviamente, con el 4ardware&
1
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 16/499
Fecha 22b*5#&(b2<<: Nombre de la competencia S pt&'*!C+'p$t$n"&*!Categoría P#&n"&p&*nt$! Universidad UPR = B*-*'7nAutor Ant+n&+ Ju$#t*! Tipo de competencia P#+@#*'*"&7nProblema ( 4
-. /$R0.1N #$ C-P
E( !&!t$'* +p$#*t&)+ UNI; p#+)$$ un "+'*n,+ ((*'*,+cmp u$ ,+! *#" &)+! - u$ ,$t$#'&n* !& !+&, nt&"+! + n+. S& (+! *#" &)+! !+n &, nt&"+!6 $( "+'*n,+ 'u$!t#* un '$n!*0$ u$ (+ &n,&"!+n6 "+'*n,+ 'u$!t#* $( n/'$#+ ,$ (`n$* - ,$ "*#*"t$# ,+n,$ *p*#$"$ (* p#&'$#* ,& $#$n"&*un p#+@#*'* u$ p#$@unt$ $( n+'5#$ ,$ ,+! *#" &)+! ,$ t$ t+ - u$ !$ "+'p+#t$ "+'+cmp. A!u'*u$ "*,* (`n$* ,$( *#" &)+ *"*5* $n cnd. V*(&,$ u$ (+! *#" &)+! $ &!t*n - u$ !$ "+'p**#" &)+! "+n n+'5#$! ,& $#$nt$!.
Archivo de Prueba & 27erreteria4t5t6(222 Martillo 2&"! 1!
$$$ ;erruc4o 1!&!! 3111 Clavos 1&!! 1"333 Pala $&!! "<<< 'ornillos 1&!! 2!""" =estornillador 3&!! $
Archivo de Prueba ' 27erreteria'4t5t6(222 Martillo 2&"! 1!$$$ >roc4a 1!&!! 3111 Pintura 1&!! 1"<<< 'ornillos 1&!! 2!
Cadena <&!! 1""" =estornillador 3&!! $
$%emplo(9ndi ue el nombre del arc4ivo ?1: abc.txtEl arc4ivo ?1 no existe, trate de nuevo&
9ndi ue el nombre del arc4ivo ?1: ferreteria.txt9ndi ue el nombre del arc4ivo ?2: abc.txtEl arc4ivo ?2 no existe, trate de nuevo&
9ndi ue el nombre del arc4ivo ?2: ferreteria.txtos nombres de los arc4ivos son i uales, trate de nuevo&
9ndi ue el nombre del arc4ivo ?2: ferreteria2.txt
os arc4ivos ferreter+a&txt y ferreteria2&txt no son i uales&a primera diferencia est) en la l+nea ?2, caracter ?"&
1:
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 17/499
Fecha 22b*5#&(b2<<: Nombre de la competencia S pt&'*!C+'p$t$n"&*!Categoría P#&n"&p&*nt$! Universidad UPR = B*-*'7nAutor Ant+n&+ Ju$#t*! Tipo de competencia P#+@#*'*"&7nProblema (
8U9AN#: C:N F$C;A0
E!"#&5* un p#+@#*'* u$ p#$@unt$ un* $" * - u$ 'u$!t#$ (* $" * ,$( p#7 &'+ ,`*. L* $" *!$# $nt#*,* $n +#'*t+mm<dd<aaaa6 ,+n,$mm $! $( '$!6dd $! $( ,`* -aaaa $! $( *9+. E( p#+@#*,$5$#_ )*(&,*# (* $" *
• E( *9+ ,$5$#_ $!t*# $nt#$ 1 - 21<<.• E( '$! ,$5$#_ $!t*# $nt#$ 1 - 12.• E( ,`* ,$5$#_ $!t*# $nt#$
o 1 - 3< p*#* (+! '$!$! 4 *5#&(%6 : 0un&+%6 !$pt&$'5#$% - 11 n+)&$'5#$%o 1 - 31 p*#* (+! '$!$! 1 $n$#+%6 3 '*#8+%6 '*-+%6 0u(&+%6 *@+!t+%6
- 12 ,&"&$'5#$%o 1 - 2 p*#* $( '$! 2 $5#$#+% !& $( *9+ n+ $! 5&!&$!t+a 1 - 2 p*#* $( '$! 2
$( *9+ $! 5&!&$!t+
$%emplo &(9ndi ue la fec4a: 11/31/2006a fec4a es incorrecta, trate de nuevo&
9ndi ue la fec4a: -11/30/2006a fec4a es incorrecta, trate de nuevo&
9ndi ue la fec4a: 11/30/2006a fec4a del pr@ximo d+a es 12A1A2!!*&
$%emplo '(9ndi ue la fec4a: 2/28/2006a fec4a del pr@ximo d+a es 3A1A2!!*&
$%emplo =(9ndi ue la fec4a: 2/28/2008a fec4a del pr@ximo d+a es 2A2BA2!! &
1
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 18/499
Fecha 22b*5#&(b2<<: Nombre de la competencia S pt&'*!C+'p$t$n"&*!Categoría Int$#'$,&+ Universidad UPR = B*-*'7nAutor N$((&u, D. T+##$! Tipo de competencia P#+@#*'*"&7nProblema 1
N)meros /ampiros
L+! n/'$#+! )*'p&#+! !+n p#+,u"t+ ,$ ,+!n/'$#+! p#+@$n&t+#$! u$ "u*n,+ !$ 'u(t&p(&"*n6 !$'$8"(*n "+n $( #$!u(t*,+. P+# $0$'p(+ (* !&@u&$nt$'u(t&p(&"*"&7n p#+,u"$ un n/'$#+ )*'p&#+ 2 ;1 X 21 . E!t+ !$ ,$5$ * u$ (+! ,`@&t+! 26 6 - 1!$ $n"u$nt#*n t*nt+ $n $( #$!u(t*,+ "+'+ $n (+!n/'$#+! p#+@$n&t+#$!. Ot#+ $0$'p(+ pu$,$ !$#1643 $( "u*( $! $( #$!u(t*,+ ,$ 3 ; 41. Un
)$#,*,$#+ n/'$#+ )*'p&#+ "u'p($ (+! !&@u&$nt$!#$ u&!&t+!
1. T&$n$n un* "*nt&,*, p*# ,$ ,`@&t+!.
2. C*,* un+ ,$ (+! n/'$#+! p#+@$n&t+#$! t&$n$ (* '&t*, ,$ (+! n/'$#+! ,$( #$!u(t*,+.
3. Un )$#,*,$#+ n/'$#+ )*'p&#+ n+ !$ "#$* *( &n"(u`#!$($ "$#+! *( &n*(. P+# $0$'p(+ 2 <6<1<6<<< X 21 6 <<6<<<6<<< n+ $! un )$#,*,$#+ n/'$#+ )*'p&#+
J*@* un p#+@#*'* u$ "*("u($ (+! )$#,*,$#+! n/'$#+! )*'p&#+! ,$ 4 p#+@$n&t+#$! X 2 ,`@
p#+@$n&t+#$! X 3 ,`@&t+!% - p#+@$n&t+#$! X 4 ,`@&t+!% ,`@&t+!.
Input (screen)
E( p#+@#*'* )* * p$,&# p+# p*nt*((* (* "*nt&,*, ,$ ,`@&t+! u$ u&$#$ "+t$0*# - !7(+ + #$"*(t$#n*t&)*! 46 : - .
Output (screen & file:vampiro.out)
E( p#+@#*'* )* '+!t#*# $n p*nt*((* - $n *#" &)+ $( #$!u(t*,+ !$@/n (+ !+(&"&t7 $( 0u$8. N)* * '+!t#*# (* "*nt&,*, ,$ n/'$#+! )*'p&#+!6 !&n+ u$ t*'5& n )* * '+!t#*# $( t+t*( $n"+nt#*,+
1
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 19/499
Corrida de ejemplo9ndi ue la cantidad de d+ itos-$,*, /: 2Cantidad indicada incorrecta, trate de nuevo
9ndi ue la cantidad de d+ itos-$,*, /: 4
1" x B3 % 13B"21 x *! % 12*!
21 x < % 1 2<2< x 1 % 21 <3! x "1 % 1"3!3" x $1 % 1$3"! x * % * !
'otal de n(meros vampiros de 4 d+ itos es: <
1
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 20/499
Fecha 22b*5#&(b2<<: Nombre de la competencia S pt&'*!C+'p$t$n"&*!Categoría Int$#'$,&+ Universidad UPR = B*-*'7nAutor N$((&u, D. T+##$! Tipo de competencia P#+@#*'*"&7nProblema 2
$l 0abuesoUn !*5u$!+ * #$"+##&,+ "+'p($t*'$nt$ un t*5($#+ *)*n8*n,+ ,$ un*"*!&((* * +t#* )$"&n* $n +#&8+nt*( + )$#t&"*( nun"* $n ,&*@+n*(% !&n p*!*# ,+! )$"$! p+# (* '&!'* "*!&((* - !&n ,$0*# n&n@un* !&n )&!&t*#. E(#$"+##&,+ !$#_ ,$( n/'$#+ '*-+# *"&* $( n/'$#+ '$n+# n+n$"$!*#&*'$nt$ t&$n$ u$ t$#'&n*# $n 1% *!t* u$ !$ (($n$n t+,+! (+!$n"*!&((*,+!.
Un $0$'p(+ ,$ un t*5($#+ ,$ 4 ; 4 $!
Para simplificar un poco el problema, se va a indicar la posición inicial en donde se va acomenzar el recorrido, el número inicial (mayor) y el tamaño del tablero va a ser fijo (6 6).
Input (file:sabueso.in)
E( p#+@#*'* )* * ($$# un *#" &)+ $n ,+n,$ (* p#&'$#* (`n$* t&$n$ (* "*nt&,*, ,$ t*5($#+! L* p#7 &'* (`n$* t&$n$ (* p+!&"&7n &n&"&*( ,$nt#+ ,$( t*5($#+ $n ,+n,$ !$ )* * "+'$n85*!$ 1%. L* t$#"$#* (`n$* )* * t$n$# $( n/'$#+ "+n $( "u*( !$ )* * "+'$n8*# $( #$"+##&,+ -$( t*5($#+ ,$ : ; : $n ,+n,$ "*,* p+!&"&7n $!t*#_ #$p#$!$nt*,* p+# un punt+ '$n+! *$n"*!&((*,+! u$ t$n@*n -* $( n/'$#+ ,$ &n&,+. C*,* n/'$#+ + punt+ $!t*#_ !$p*#*,+ p+# u$n 5(*n"+. S& *- '_! ,$ un t*5($#+6 *5#_ un* (`n$* u$ !$p*#$ un t*5($#+ ,$ +t#+ !$@ p+!&"&7n &n&"&*( ,$( t*5($#+ - $n (* p#7 &'* (`n$* $( n/'$#+ &n&"&*(.
2<
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 21/499
Output (file:sabueso.out)
E( p#+@#*'* @u*#,*#_ $n un *#" &)+ "*,* t*5($#+ "+n !u! "+##$!p+n,&$nt$! !+(u"&+n$&n,&"*# u$ p*#* *"&(&,*, ,$ ($"tu#* ,$ (+! #$!u(t*,+! p+# p*#t$ ,$ (+! 0u$"$!6 * u$((+! n/* ,$5$n t$n$# un $!p*"&+ *,&"&+n*( *( #$nt$ p*#* u$ u$,$ $( t*5($#+ "+'p($t*'$nt$ A u$((* p*#$0* u$ !+'$t* un #$!u(t*,+ u$ n+ &n"(u-* $!t$ +#'*t+6 !*"*#_ unincorrect output - (* p$n*(&,*, ,$ t&$'p+ u$ !$ &n,& u$ $n (*! #$@(*! ,$ (*! "+'p$t$n"&*!.
Test #ata .nput(13 33<& & & & & 22& & & 33 & && 3! & & & &$ & & & && 12 & & & && & & & & 1<
Test #ata :utput(2< 2* 2" 2$ 23 222 31 32 33 3$ 212B 3! 3< 3* 3" 2! $ " * < 1B 3 12 11 1! B 1 2 13 1$ 1" 1* 1<
21
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 22/499
Fecha 22b*5#&(b2<<: Nombre de la competencia S pt&'*!C+'p$t$n"&*!Categoría Int$#'$,&+ Universidad UPR = B*-*'7nAutor N$((&u, D. T+##$! Tipo de competencia P#+@#*'*"&7nProblema 3
SOLON File S stem ! "ll File Si#eDefinición del problemaE( !&!t$'* +p$#*t&)+ VSD>U(t#& V&!t* ut&(&8* $( !&!t$'* ,$ *#" &)+! SOLON. E!t$ !&!t$'* ut&(&8* un* t,$ *#" &)+! F&($ A((+"*t&+n T*5($% ,$ 32 5&t! ((*'*,* $( SOLON>FAT. Un $0$'p(+ ,$( SOLON>FAT !&@u$"+nt&nu*"&7n
.# Filename FC .n>lin3 0tart>Addr $nd>Addr1 *+?&.@& 1 <1<< <12:2 $t $#$*(.t t 1 2<<3 2<1:3 &n&,$nt.,(( 1 <<33 << 34 *+?&.@& < < << 4 << <
*+?&.@& < 4 < << 1<24: &n&,$nt.,(( < < <2 1 <4:<
$t $#$*(.t t < < <<<1 <<32&n&,$nt.,(( < : <12 <2<<
E( SOLON>FAT !$ "+'p+n$ ,$ (+ !&@u&$nt$• C*,* $nt#*,* $n $( SOLON>FAT $!t_ &,$nt& &"*,* "+n un n/'$#+ n*tu#*( 16263 % - $!$ $! !u ID ,$nt#+
t*5(*. S&$'p#$ "+'&$n8* $n 1%.• J*- un "*'p+ binario (0,1) u$ &,$nt& &"* $( p#&n"&p&+ ,$( *#" &)+. E!t$ "*'p+ !$ ($ ((*'* $( First-Chain FC%.• J*- un "*'p+ ((*'*,+ in-link u$ &,$nt& &"* (* p+!&"&7n ,$nt#+ ,$( SOLON>FAT ,$( p#7 &'+ !$@'$nt+
#$ $#$nt$ *( *#" &)+ ,$ &n&,+ $n $( "*'p+ ,$ filename . S& $!t$ "*'p+ $!t_ $n < !&@n& &"* u$ !t$ $! $( /(t&'!$@'$nt+ ,$( *#" &)+.
• L+! "*'p+! ,$ Start-Addr *n, End-Addr &,$nt& &"*n ,+n,$ "+'&$n8* - t$#'&n* $!$ !$@'$nt+ ,$ ,*t+! #$ $#*#" &)+ ,$!"#&t+ $n filename .
P+# $0$'p(+ $( *#" &)+ao i& if t&$n$ 3 $nt#*,*! $n $( SOLON>FAT IDS 16 - 4%. E( *#" &)+ $!t* ,&)&,&,+ !$@'$nt+!. E( p#&'$# !$@'$nt+ "+'&$n8* $n (* p+!&"&+n 1<< - t$#'&n* $n (* 12:6 $( !$@un,+ !$@'$nt+ "+'&$<< - t$#'&n* $n (* p+!. 1<246 - $( u(t&'+ !$@'$nt+ "+'&$n8* $n (* p+!&"&+n 4 - t$#'&n* $n (* <.El programa
U!t$, ,$5$#_ "+n!t#u&# un p#+@#*'* u$ ,*,+ un *#" &)+ SFAT.T;T pu$,* "*("u(*# $( t*'*9+ ,$ t+,+! (+! *#" &)+"+nt$n&,+! $n $( SFAT.
E0$'p(+ D*,+ un SFAT.T;T "+'+ $( p#$!$nt*,+ *nt$#&+#'$nt$ !u !&!t$'* ,$!p($@*#_ $n p*nt*((*
ao i& if "< bytes 3 se mentoset4ereal&txt "< bytes 2 se mentoswinident&dll 3!* bytes 3 se mentos
IMPORTANTE:• E( p#&'$# !$@'$nt+ ,$ t+,+! (+! *#" &)+! "+nt$n&,+! $n $( SOLON>FAT $!t_n $n (*! p#&'$#*! p+!&"• Un *#" &)+ pu$,$ $!t*# @u*#,*,+ $n 1 + '_! !$@'$nt+!.• S& un !$@'$nt+ $'p&$8* $n (* p+!&"&7n 1 - t$#'&n* $n (* 3 $! ,$ t*'*9+ 3 -N: ,$ t*'*9+ 3>1%X2. E!t+ $!
"&$#t+ -* u$ $(byte 16 2 - 3 p$#t$n$"$n *( '&!'+ !$@'$nt+.P*#* $!t$ p#+5($'* $( n/'$#+ '*-+# ,$ $nt#*,*! $n $( SOLON>FATno e5ceder* nunca 2<.
22
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 23/499
Fecha 22b*5#&(b2<<: Nombre de la competencia S pt&'*!C+'p$t$n"&*!Categoría Int$#'$,&+ Universidad UPR = B*-*'7nAutor ACM Tipo de competencia P#+@#*'*"&7nProblema 4
B:-BA0E( 0u$@+ ines!eeper !$ 5*!* $n &# *,&)&n*n,+ $n ,+n,$ !$$n"u$nt#*n (*! 5+'5*! +"u(t*!. P*#* u$ $( 0u@*,+# pu$,*,$t$#'&n*# $n ,+n,$ !$ $n"u$nt#*n6 ut&(&8* ,$ #$ $#$n"&* (+!n/'$#+! u$ ($ )*n &n,&"*n,+ (* p#+ &'&,*, ,$ (*! 5+'5*!.D$ (* '&!'* +#'* )*'+! * *n*(&8*# (+! n/'$#+! ,$ un t*5($#+
p*#* ,$t$#'&n*# $n ,+n,$ !$ $n"u$nt#*n (*! ,& $#$nt$! 5+'5*!. C*,* n/'$#+ &n,&"*"u_nt*! 5+'5*! *- $n (*! "*!&((*! )$"&n*!6 $n +#&8+nt*(6 )$#t&"*( - ,&*@+n*(. N&n@un* "*!&((* (($)* '_! ,$ un* 5+'5* - ,+n,$ *- n/'$#+ n+ *- 5+'5*. J*@* un p#+@#*'*($* ,$ un *#" &)+ un* !$#&$ ,$ t*5($#+! - @u*#,$ (+! #$!u(t*,+! $n +t#+ *#" &)+.
InputE( *#" &)+ "+'$n8*#_ "+n un* p#&'$#* (`n$* u$ &n,&"*#_ $( nu'$#+ ,$ t*5($#+! u$ !$ )*nE( p#7 &'+ #$"+#, ,$5$ "+nt$n$# (* "*nt&,*, ,$ &(*! - "+(u'n*! u$ "+nt&$n$ $( t*5($#+Lu$@+ ,$5$ !$@u&# $( t*5($#+. En * u$((+! $n"*!&((*,+! u$ n+ (($)* n/'$#+6 !$ )* *p+n$#C*,* p+!&"&7n )* * $!t*# !$p*#*,* ,$ un $!p*"&+ $n 5(*n"+. C*,* t*5($#+ )* * t$n$# !u! ,&)* * $!t*# !$p*#*,+ ,$ (* +t#* t*5(* p+# un* (`n$* $n 5(*n"+.
OutputL* !*(&,* "+n!&!t$ $n '+!t#*# $( t*5($#+ "+n !u! "+##$!p+n,&$nt$! 5+'5*!. L*! 5+'5*! !$ )*n,&5u0*# ut&(&8*n,+ $( *!t$#&!"+ e%. En ,+n,$ n+ *- 5+'5*!6 !$ ,$0* $( punt+. E( p#+@#
)*(&,*# "u*( u&$# p+!&5($ $##+# u$ pu$,* !u#@&# ,$ ($$# (+! ,*t+!. A( &n*( !$ ,$5$ &n, 5+'5*! $n"+nt#*,*! $n $( t*5($#+.Sample Input (File: bombas.in)1$ $& & 2 &1 2 & && & & $& & & &Sample Output (File:bombas.out)& . 2 &
1 2 & .& & . $& & . .'otal de bombas: "
23
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 24/499
Fecha 22b*5#&(b2<<: Nombre de la competencia S pt&'*!C+'p$t$n"&*!Categoría Int$#'$,&+! Universidad UPR = B*-*'7nAutor Ant+n&+ Ju$#t*! Tipo de competencia P#+@#*'*"&7nProblema (
F$C;A0 #$! FUTUR:
E!"#&5* un p#+@#*'* u$ p#$@unt$ un* $" * - un n/'$#+ p+!&t&)+n - u$ 'u$!t#$ (* $" * ,$ n ,`*!$n $( utu#+. L* $" * ,$5$#_ !$# $nt#*,* $n +#'*t+mm<dd<aaaa6 ,+n,$mm $! $( '$!6dd $! $( ,`* -aaaa $! $( *9+. E( p#+@#*'* ,$5$#_ )*(&,*# (* $" *
• E( *9+ ,$5$#_ $!t*# $nt#$ 1 - 21<<.• E( '$! ,$5$#_ $!t*# $nt#$ 1 - 12.• E( ,`* ,$5$#_ $!t*# $nt#$
o 1 - 3< p*#* (+! '$!$! 4 *5#&(%6 : 0un&+%6 !$pt&$'5#$% - 11 n+)&$'5#$%o 1 - 31 p*#* (+! '$!$! 1 $n$#+%6 3 '*#8+%6 '*-+%6 0u(&+%6 *@+!t+%6
- 12 ,&"&$'5#$%o 1 - 2 p*#* $( '$! 2 $5#$#+% !& $( *9+ n+ $! 5&!&$!t+a 1 - 2 p*#* $( '$! 2
$( *9+ $! 5&!&$!t+
$%emplo &(9ndi ue la fec4a: 11/31/2006El d+a es incorrecto para el mes indicado, trate de nuevo&
9ndi ue la fec4a: -11/25/2006El mes es incorrecto, trate de nuevo&
9ndi ue la fec4a: 11/25/2106El a o es incorrecto, trate de nuevo&
9ndi ue la fec4a: 11/25/20069ndi ue el n(mero: -8El n(mero es no es positivo, trate de nuevo&
9ndi ue la fec4a: 11/25/20069ndi ue el n(mero: 8a fec4a d+as en el futuro es 12A3A2!!*
$%emplo '(9ndi ue la fec4a: 2/28/20069ndi ue el n(mero: 4a fec4a $ d+as en el futuro es 3A$A2!!*&
$%emplo =(9ndi ue la fec4a: 2/28/20089ndi ue el n(mero: 4a fec4a $ d+as en el futuro es 3A3A2!! &
24
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 25/499
Fecha 22b*5#&(b2<<: Nombre de la competencia S pt&'*!C+'p$t$n"&*!Categoría E p$#t+ Universidad UPR = B*-*'7nAutor N$((&u, D. T+##$! Tipo de competencia P#+@#*'*"&7nProblema 1
Klingon Paths
En (* !$#&$ ,$Star "rek (* #*8* ?&n@(+n&*n* klin#on % !$ "*#*"t$#&8* p+# !$# @#*n,$! @u$##$#+! - n+ t$n$# '&$,+ * (* 'u$#t$. Du#*nt$ un*,$ !u! '/(t&p($! @u$##*!6 !$ $n"+nt#*#+n "+n un $n$'&@+ u$ #$@&!t#*(* (+"*(&8*"&7n ,$ "*,* n*)$ !$@/n $nt#* $n "*,* "u*,#*nt$. S& (*n*)$ )u$()$ *( '&!'+ (u@*#6 !$ *"t&)* un* 5+'5* u$ ,$!t#u-$ $("u*,#*nt$ "+'p($t+. C+'+ (+! klin#ons n+ t&$n$n '&$,+ * (*'u$#t$6 $n)&*#+n * un $!p`* * $ p(+#*# un !$"t+# p+# ,+n,$ $((+!
p+,#`*n &n)*,&#. E( $!p`* ,$5$ $n"+nt#*# (* #ut* '_! (*#@* p+!&5($ p*#* p+,$# (($@*# *( p(*n$t* ,$ (+! $n$'&@+!. L* n*)$ !7(+ !$ pu$,$'+)$# +#&8+nt*( + )$#t&"*('$nt$ ,$ un "u*,#*nt$ * +t#+. C*,*"u*,#*nt$ t&$n$ un n/'$#+ - $!t$ n/'$#+ pu$,$ #$p$t&#!$ $n +t#+"u*,#*nt$. L* n*)$ ,$5$ p*!*# $nt#$ (+! "u*,#*nt$! ,$ '+,+ t*( u$n+ )&!&t$ un "u*,#*nt$ u$ t$n@* $( '&!'+ n/'$#+ n& )&!&t*# $('&!'+ "u*,#*nt$. J*@* un p#+@#*'* u$ ,$t$#'&n$ "u*( $! (* #ut*'_! (*#@* ,$nt#+ ,$ un !$"t+# ,$t$#'&n*,+.
Input
E( *#" &)+ "+'$n8*#_ "+n un* p#&'$#* (`n$* u$ &n,&"*#_ $( nu'$#+ ,$ !$"t+#$! u$ !$ )*nL* p#7 &'* (`n$* ,$5$ "+nt$n$# (* "*nt&,*, ,$ &(*! - "+(u'n*! u$ "+nt&$n$ $( !$"t+#. Lu!$@u&# (* t*5(* u$ t&$n$ $n "*,* &nt$#!$""&7n "u*,#*nt$% un n/'$#+ ,$( < *( !$p*$!p*"&+ $n 5(*n"+.
Output
L* !*(&,* "+n!&!t$ $n un p*# ,$ n/'$#+! $nt#$ p*# nt$!&! u$ &n,&"*n (* "++#,$n*,* &n&"&"u*,#*nt$ 5*!$ 1% $n ,+n,$ "+'&$n8* (* #ut*. En un* p#7 &'* (`n$* !$ 'u$!t#* (* (&!t* ,$ n/!$@u&# !$p*#*,+ p+# un $!p*"&+ $n 5(*n"+. Pu$,$ *5$# )*#&*! !+(u"&+n$! u$ ,$n $( '&! p*!+!. En $!t$ "*!+ !$ 'u$!t#*n t+,*! (*! !+(u"&+n$!.
2
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 26/499
Sample Input (File: $lin%on.in)
13 3 * 2! 3
3 1< B2! 1! *
Sample Output ($lin%on.out)-1,1/*D2!D3DBD1<D1!*D3D2!D1!D1<DB
-1,2/2!D3DBD*D1!D1<
-1,3/
3D2!D1<DBD*D1!3DBD*D1!D1<D2!
-2,1/3D1<DBD*D1!D2!3D2!D1!D*DBD1<
-2,2/1<D2!D3DBD*D1!1<DBD*D1!D2!D31<D1!D*DBD3D2!1<D3D2!D1!D*DB
-2,3/BD3D2!D1<D1!D*BD1<D3D2!D1!D*BD*D1!D2!D3D1<
-3,1/2!D3D1<DBD*D1!2!D1!D*DBD1<D3
-3,2/1!D2!D3D1<DBD*1!D1<D2!D3DBD*1!D*DBD3D2!D1<
-3,3/*DBD3D2!D1<D1!*D1!D1<D2!D3DB*D1!D2!D3D1<DB
* 2! 3
3 1< B
2! 1! *
2:
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 27/499
Fecha 22b*5#&(b2<<: Nombre de la competencia S pt&'*!C+'p$t$n"&*!Categoría E p$#t+ Universidad UPR = B*-*'7nAutor Hu*n S+(_ Tipo de competencia P#+@#*'*"&7nProblema 2
SOLON File S stem efra%mentator '.
Definición del problema
E( !&!t$'* +p$#*t&)+ VSD>U(t#& V&!t* ut&(&8* $( !&!t$'* ,$ *#" &)+! SOLON. E!t$ !&!t$'* ut&(&8* un* t,$ *#" &)+! F&($ A((+"*t&+n T*5($% ,$ 32 5&t! ((*'*,* $( SOLON>FAT. Un $0$'p(+ ,$( SOLON>FAT !&@u$"+nt&nu*"&7n
.# Filename FC .n>lin3 0tart>Addr $nd>Addr1 b,*t*b&'*@$!b*+?&.@& < < <1<< <12:2 b +'$b0u*nb$t $#$*(.t t 1 2<A3 21<C3 b#!-n"b5*"?upb &n&,$nt.,(( < < <<3B << C4 b$t"b"#+nt*5."+n 1 < << D << Cb,*t*b&'*@$!b*+?&.@& 1 1 < <F 1<2A: b"-@>,&!?b &n,+ !b#!-n".$ $ 1 < <2 1 <4:<
b +'$b0u*nb$t $#$*(.t t < < <<<1 <<3Ab#!-n"b5*"?upb &n&,$nt.,(( 1 3 <12 <1 F
E( SOLON>FAT !$ "+'p+n$ ,$ (+ !&@u&$nt$
• C*,* $nt#*,* $n $( SOLON>FAT $!t_ &,$nt& &"*,* "+n un n/'$#+ n*tu#*( 16263 % - $!$ $! !u ID ,$nt#+t*5(*. N+ n$"$!*#&*'$nt$ "+'&$n8*n $n 1 p$#+ !& !+n !$ u$n"&*($!%.
• J*- un "*'p+ binario ($oolean) u$ &,$nt& &"* $( p#&n"&p&+ ,$( *#" &)+. E!t$ "*'p+ !$ ($ ((*'* $( First-ChainFC%.
• J*- un "*'p+ ((*'*,+ in-link u$ &,$nt& &"* (* p+!&"&7n ,$nt#+ ,$( SOLON>FAT ,$( p#7 &'+ !$@'$nt+ #$ $#$nt$ *( *#" &)+ ,$ &n&,+ $n $( "*'p+ ,$ filename . S& $!t$ "*'p+ $!t_ $n < !&@n& &"* u$ $!t$ $! $( /(t&!$@'$nt+ ,$( *#" &)+.
• L+! "*'p+! ,$ St*#t>A,,# *n, En,>A,,# &,$nt& &"*n ,+n,$ "+'&$n8* - t$#'&n* $!$ !$@'$nt+ ,$ ,*t+! #$ $#*#" &)+ ,$!"#&t+ $n filename . NOTE u$ (*! p+!&"&+n$! !+n $ *,$"&'*($!%.
P+# $0$'p(+ $( *#" &)+AdataAima esAao i& if t&$n$ 2 $nt#*,*! $n $( SOLON>FAT IDS - 1%. E( *#" &)+ $,&)&,&,+ $n 2 !$@'$nt+!. E( p#&'$# !$@'$nt+ "+'&$n8* $n (* p+!&"&+n < <F - t$#'&n* $n (* 1<2A - $( !$@un"+'&$n8* $n (* p+!. <1<< - t$#'&n* $n (* p+!. <12:.
El programa
U!t$, ,$5$#_ "+n!t#u&# un p#+@#*'* u$ ut&(&"$ (+! *#" &)+! SFAT.IN - ISO.IN - @$n$#*# (+! *#" &)+! SFAISO.OUT. E( *#" &)+ SFAT.IN "+nt&$n$ $( SOLON>FAT - $( *#" &)+ ISO.IN "+nt&$n$ un* &'*@$n ,$( ,&!"+,$5$#_ ut&(&8*# $( SFAT.IN p*#* ,$ #*@'$nt*# $( ISO.IN. E0$'p(+
2
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 28/499
SFAT.IN
1 c,*t*c*.t t 1 3 <<1 <<2 c,*t*c5.t t 1 4 <<: <133 c,*t*c*.t t < < <14 <2<4 c,*t*c5.t t < < <21 <2A
ISO.IN
C*"tuT$##- Fun? )! H*"? )!. S*5uR&"? F(*&#
Lu$@+ ,$( D$ #*@ !u !&!t$'* ,$5$ @$n$#*#
SFAT.OUT
1 c,*t*c*.t t 1 < <<1 <142 c,*t*c5.t t 1 < <1 <2D
ISO.OUTC*"tu! H*"? )!. S*5uT$##- Fun? )!. R&"? F(*&#
IMPORTANTE: N+ *!u'* u$ $( ISO.IN $! un *#" &)+ ,$ t$ t+. A5!t#*&@* ,$ u$ $( '&!'+ $! un* "+n"*t$n*"& 5-t$! !&n !$nt&,+ - (+ u$ ($ ,* $( !$nt&,+ $! $( p#+@#*'* u$ (+! ($*. P+# $0$'p(+ ISO.IN puun* "+n"*,$n*"&7n ,$ &'_@$n$! *!` "+'+ $( ISO.IN ,$( $0$'p(+ $! un* "+n"*,$n*"&7n ,$ t$ t+
2
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 29/499
Fecha 22b*5#&(b2<<: Nombre de la competencia S pt&'*!C+'p$t$n"&*!Categoría E p$#t+ Universidad UPR = B*-*'7nAutor ACM Tipo de competencia P#+@#*'*"&7nProblema 3
So Doku C ecker T $ 5$!t (+@&"*( pu88($! + t$n *#$ pu88($! t *t *#$ 5*!$, +n * !&'p($ &,$*. S+ D+?u &! +n pu88($. A(t +u@ S+ D+?u! *)$ 5$$n *#+un, +# !+'$ t $nt- -$*#!6 &n t $ (*!t $ -$*#!"+n u$#$, t $ +#(, $ p+n$nt&*((-. Jun,#$,! + n$ !p*p$#! *n, $5!&t$! *#$ n+ pu5(&! &n@ t* ,*&(- 5*!&!. F+# t +!$ + -+u un *'&(&*# &t t $!$ pu88($!6 ($t '$ @&)$ * 5#&$ &nt#+,u"
T $ p&"tu#$ *5+)$ "+nt*&n! *n $ *'p($ + * Su D+?u pu88($. A! -+u "*n !$$6 $ *)$ * ; @#&&(($, &t !&n@($ ,&@&t! #+' 1 t+ *n, $'pt- p(*"$!. T $ @#&, &! u#t $# ,&)&,$, &nt+ n&n@#&,!6 &n,&"*t$, 5- t $ t &"? (&n$!. T+ !+()$ t $ pu88($ -+u *)$ t+ &(( t $ $'pt- p(*"$! &t *""+#,&n@ t+ t $ +((+ &n@ #u($!
• E)$#- #+ ! +u(, "+nt*&n t $ ,&@&t! 1 t+ $ *"t(- +n"$a• E)$#- "+(u'n ! +u(, "+nt*&n t $ ,&@&t! 1 t+ $ *"t(- +n"$a• E)$#- 3;3 !u5>@#&, ! +u(, "+nt*&n t $ ,&@&t! 1 t+ $ *"t(- +n"$.
A $(( +#'$, Su D+?u "*n 5$ !+()$, &t p*p$# *n, p$n"&( u!&n@ (+@&"*( ,$,u"t&+n +n(-. T+#'$, &t ! +u(, 5$ ($@*( n+ #+ 6 "+(u'n +# !u5>@#&, "+nt*&n! * ,&@&t '+#$ t *n +n"$%6
$'pt- p(*"$! "*n *(( 5$ &(($, &($ #$!p$"t&n@ t $ #u($!% *n, un& u$ t $#$ &! +n(- +n$ !+(u&! *t -+u# p#+@#*' &! @+&n@ t+ " $"?.InputT $ &nput "+nt*&n! !$)$#*( p*#t&*((-% &(($, @#&,!6 $*" #$p#$!$nt&n@ * Su D+?u pu88($ t $#$ *#$ (&n$! &t ,&@&t! @&)&n@ t $ pu88($ &n #+ '*0+# +#,$#. E'pt- p(*"$*#$ #$p#$!$nt$, 5- t $ ,&@&t < 8$#+%. D&@&t! +n * (&n$ *#$ !$p*#*t$, 5- +n$ !p*!$p*#*t$, 5- +n$ $'pt- (&n$.T $ &#!t @#&, &n t $ !*'p($ &nput #$p#$!$nt! t $ pu88($ @&)$n &n t $ p&"tu#$.
2
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 30/499
:utputF+# $)$#- @#&, &n t $ &nput6 ,$t$#'&n$ +n$ + t $ +((+ &n@ +u# )$#,&"t!
• I(($@*( & t $ pu88($ )&+(*t$! +n$ + t $ t #$$ #u($!a• Un& u$ & +n(- +n$ !+(ut&+n $ &!t!a• A'5&@u+u! & '+#$ t *n +n$ !+(ut&+n $ &!t!a• I'p+!!&5($ & n+ !+(ut&+n $ &!t!a• I t $ p#+5($' &! un& u$6 ! + t $ !+(ut&+n
P#&nt +n$ (&n$ p$# @#&,6 &n t $ +#'*t C*!$ fNZ fVERDICTZ. 6 $#$ N &! t $ "*!$ nu'5$#6 !t*#t&n@VERDICT &! +n$ + t $ +u# +#,! &n t $ (&!t. S$$ t $ !*'p($ +utput +# t $ $ *"t +#'*t.
Note *n I(($@*( pu88($ &! *(!+ I'p+!!&5($ 6 + "+u#!$6 5ut -+u# p#+@#*' ! +u(, p#&ntt *t "*!$. On(- p#&nt I'p+!!&5($ & t $ &nput ,+$!n t )&+(*t$ +n$ + t $ t #$$ #u($!6 5ut t $ p"*n t 5$ !+()$,.
0ample .nput :utput 7or 0ample .nput0 0 3 9 0 0 ! 6 00 4 0 0 0 6 0 0 96 0 ! 0 1 0 0 0 42 0 0 6 ! 0 0 9 00 0 4 3 0 5 6 0 00 1 0 0 4 9 0 0 !! 0 0 0 9 0 2 0 13 0 0 2 0 0 0 4 00 2 9 0 0 8 5 0 0
0 0 3 9 0 0 ! 6 00 4 0 0 0 6 0 0 96 0 0 0 1 0 0 0 40 0 0 6 ! 0 0 9 00 0 4 0 0 5 6 0 00 1 0 0 4 9 0 0 0! 0 0 0 9 0 2 0 13 0 0 2 0 0 0 4 0
0 2 0 0 0 8 5 0 0
0 0 3 9 0 0 ! 6 00 4 0 0 0 6 0 0 96 0 ! 0 1 0 0 0 42 0 0 6 ! 0 0 9 00 0 4 3 0 5 6 0 00 1 0 0 4 9 0 0 !! 2 0 0 9 0 2 0 13 0 0 2 0 0 0 4 00 2 9 0 0 8 5 0 0
0 0 3 9 0 0 ! 6 00 4 0 0 0 6 0 0 96 0 ! 0 1 0 0 0 42 0 0 6 ! 0 0 9 00 0 4 3 0 5 6 0 00 1 0 0 4 9 0 0 !! 5 0 0 9 0 2 0 13 0 0 2 0 0 0 4 00 2 9 0 0 8 5 0 0
"ase 1# $ni%ue.1 " 3 B $ < * 2 $ 2 < 3 * 1 " B* B < " 1 2 3 $2 3 * < 1 $ B "B < $ 3 2 " * 1 " 1 * $ B 3 2 << * " $ B 3 2 13 1 2 " < B $ *$ 2 B 1 * " < 3
"ase 2# &mbiguous."ase 3# 'llegal."ase 4# 'mpossible.
3<
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 31/499
Fecha 22b*5#&(b2<<: Nombre de la competencia S pt&'*!C+'p$t$n"&*!Categoría E p$#t+ Universidad UPR = B*-*'7nAutor ACM Tipo de competencia P#+@#*'*"&7nProblema 4
-apping the RouteF&n,&n@ * p*t t #+u@ * '*8$ &! * p+pu(*# p#+5($' +# "+'put$#!. In t &! p#+5($'6 * '*8$ &"+n!&!t + * #$"t*n@u(*# *##*- + ! u*#$ "$((!6 $*" + &" '*- *)$ *((! +n t $ n+#t 6 !+ut 6 *n,b+# $!t !&,$! + t $ "$((. On$ "$(( &(( 5$ &,$nt& &$, *! t $ !t*#t&n@ p+&nt6 *n, *n+t $#&,$nt& &$, *! t $ @+*(. Y+u# t*!? &! t+ &n, t $ un& u$ #+ut$ #+' t $ !t*#t&n@ p+&nt t+ t $$*" "$(( &n t $ p*t &t &t! !$ u$n"$ &n t $ p*t 6 &,$nt& - t $ "$((! t *t $#$ )&!&t$, 5ut t *t &n t $ p*t 6 *n, ,&!p(*- t $ '*8$.T $ *(@+#&t ' -+u u!$ t+ &n, * p*t t #+u@ t $ '*8$ 'u!t 5$ t $ +n$ ,$!"#&5$, 5$(+ . I'*@&n$#+5+t &! p+!&t&+n$, &n t $ !t*#t&n@ "$((. T $ #+5+t &#!t *tt$'pt! t+ @+ $!t #+' t *t "$((6 t $n $*!t6 t $n !+ut 6 &n !$ u$n"$. T $ #+5+t "*n '+)$ &n t $ !$($"t$, ,&#$"t&+n &
*% t $#$ &! n+ *(( p#$)$nt&n@ &t #+' '+)&n@ &n t *t ,&#$"t&+n6 *n,
5% &t *! n+t -$t 5$$n &n t $ n$ t "$(( &n t *t ,&#$"t&+n.K $n t $ #+5+t #$*" $! t $ @+*(6 &t! t#&p &! +)$#. I t $ #+5+t #$*" $! * "$(( *t &" n+ u#t&! p+!!&5($6 &t #$t#$*t! t+ t $ p#$)&+u! "$(( &t +""up&$, *n, *tt$'pt! t+ '+)$ &n t $ n$ t unt,&#$"t&+n.
C+n!&,$# t $ !&'p($ '*8$ ! + n +n t $ ($ t 5$(+ . It &! t + "$((! &@ *n, t #$$ "$((! &,$. T $!t*#t&n@ "$(( &! (*5$($, g; *n, t $ @+*( "$(( &! (*5$($, g. K $n t $ #+5+t !t*#t!6 &t +u(, &#!t t#- t+'+)$ $!t ($ t%6 5ut &n,! * *((. It t $n t#&$! t+ '+)$ n+#t up%6 *n, &! *@*&n 5(+"?$, 5- * *(( *(!+ p#$)$nt! &t #+' '+)&n@ $*!t #&@ t%6 !+ &t &n*((- t#&$! t+ '+)$ !+ut ,+ n%6 *nF#+' t $ n$ "$(( &t &(( $)$ntu*((- '+)$ $*!t. J$#$ &t #$p$*t! &t! '+)$'$nt *(@+#&t '. A(t +u@
*(( 5(+"?! &t! p+t$nt&*( $!t *#, '+)$'$nt6 &t *! *(#$*,- )&!&t$, t $ "$(( &n t *t ,&#$"t&+n6t#&$! t+ '+)$ n+#t 6 *n, &! !u""$!! u(. Un +#tun*t$(-6 * t$# '+)&n@ n+#t 6 &t &n,! n+ *- t+ p*t 6 *n, !+ &t #$t#$*t! t+ t $ p#$)&+u!(- +""up&$, "$((. N+ &t t#&$! t+ '+)$ $*!t6 *n, &! !uF#+' t *t "$(( &t &(( '+)$ n+#t 6 *n, t $#$ &t &n,! t $ @+*(. T $ '*8$ t *t +u(, 5$ ,&!p(*-$, +n+utput &! ! + n +n t $ #&@ t 5$(+ . N+t$ t *t t $ !t*#t&n@ "$(( &! (*5$($, g1 6 $*" "$(( &n t $ p*t t+ t $@+*( &n"(u,&n@ t $ +n$ "+nt*&n&n@ t $ @+*(% &! (*5$($, &t &t! !$ u$n"$ nu'5$#6 *n,*! )&!&t$, 5ut &! n+t &n t $ p*t &! (*5$($, &t u$!t&+n '*#?!.
FDDDFDDDFDDDF FDDDFDDDFDDDF G ; G G G G 1G G "G F F F F F F F F G G G 2 3 $G FDDDFDDDFDDDF FDDDFDDDFDDDF
.nputV&$ t $ '*8$ *! *n *##*- + "$((!6 &t t $ n+#t $#n'+!t #+ 5$&n@ #+ 16 *n, t $ $!t$#n'+!t"+(u'n 5$&n@ "+(u'n 1. In t $ '*8$ *5+)$6 t $ !t*#t&n@ "$(( &! #+ 16 "+(u'n 16 *n, t $ @+*( #+ 16 "+(u'n 3.
T $#$ &(( 5$ +n$ +# '+#$ '*8$! t+ p#+"$!! &n t $ &nput. F+# $*" '*8$ t $#$ &(( &#!t *pp$*&nt$@$#!. T $ &#!t t + @&)$ t $ $&@ t nu'5$# + #+ !% *n, &,t nu'$# + "+(u'n!% + t $ '*
31
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 32/499
"$((!%. T $ n$ t t + @&)$ t $ p+!&t&+n #+ *n, "+(u'n nu'5$#% + t $ !t*#t&n@ "$((6 *n, t $ @&)$ t $ p+!&t&+n + t $ @+*(. N+ '*8$ &(( *)$ '+#$ t *n 12 #+ ! +# 12 "+(u'n!6 *n, t $#$ &*( *-! 5$ * p*t #+' t $ !t*#t&n@ p+&nt t+ t $ @+*(.
F+((+ &n@ t $ &#!t !& &nt$@$#! t $#$ &(( *pp$*# +n$ &nt$@$# +# $*" "$((6 &n #+ '*0)*(u$ + $*" &nt$@$# &n,&"*t$! $t $# * "$(( *! * *(( +n &t! $*!t$#n !&,$ 1% *n, $t $# &*(( +n &t! !+ut $#n !&,$ 2%. F+# $ *'p($6 * "$(( &t n+ $*!t$#n +# !+ut $#n *(( *! * )*(u$ +"$(( &t +n(- * !+ut $#n *(( *! * )*(u$ + 2. A "$(( &t 5+t *n $*!t$#n *n, * !+ut $#n *(( *! )*(u$ + 3. T $ "$((! +n t $ p$#&p $#- + t $ '*8$ *( *-! *)$ *pp#+p#&*t$ *((! t+ p#$)$nt t $ ##+' ($*)&n@ t $ '*8$a t $!$ *#$ n+t !p$"& &$, &n t $ &nput ,*t*.
T $ (*!t '*8$ &n t $ &nput ,*t* &(( 5$ +((+ $, 5- !& 8$#+$!.:utputF+# $*" '*8$6 ,&!p(*- t $ '*8$ *! ! + n &n t $ $ *'p($ *5+)$ *n, t $ $ p$"t$, +utput 5$(+ 6*pp#+p#&*t$(- (*5$($, *n, p#$ & $, 5- t $ '*8$ nu'5$#. T $ '*8$! *#$ nu'5$#$, !$ u$nt&*((- !t*&t 1.
0ample .nput2 3 1 1 1 31 1 !! ! !
$ 3 3 2 $ 3! 3 !! 2 !! 3 !! 1 !
! ! ! ! ! !
0ample :utputMaHe 1
FDDDFDDDFDDDFG 1G G "GF F F FG 2 3 $GFDDDFDDDFDDDF
MaHe 2
FDDDFDDDFDDDFG G GF FDDDF F
G 3 $ "GF FDDDF FG 2 1G *GF FDDDF FG G <GFDDDFDDDFDDDF
32
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 33/499
Fecha 22b*5#&(b2<<: Nombre de la competencia S pt&'*!C+'p$t$n"&*!Categoría E p$#t+ Universidad UPR = B*-*'7nAutor ACM Tipo de competencia P#+@#*'*"&7nProblema
The Boggle 9ameT $ (*n@u*@$ P&@E u *! * )$#- !&'p($ !-nt* . E*" +#, &n t &! (*n@u*@$ *! $ *"t(- 4 ($tt$*" +#, "+nt*&n! $ *"t(- t + )+ $(! - &! "+n!&,$# * )+ $( &n P&@E u%. F+# &n!t*n"$6 '**#$)$n *#$ ($@&t&'*t$ +#,!6 *#t! &! n+t * ($@*( +#,.
In t $ @*'$ 5+@@($6 -+u *#$ @&)$n * 4 4 *##*- + ($tt$#! *n, *!?$, t+ &n, *(( +#,! "+nt*&+#, &n +u# "*!$ P&@E u% &(( t u! 5$ * !$ u$n"$ + 4 ,&!t&n"t ! u*#$! ($tt$#!% t *t +#' * *n, !u" t *t $*" ! u*#$ t+u" $! *)$ * "+#n$# +# $,@$ &n "+''+n% t $ n$ t ! u*#$.
F+# $ *'p($
6 ; ; =; > E I
J K 9 L 7 7
In t &! 5+*#, * p*#t&*(% (&!t + ($@*( +#,! &n"(u,$
6; 7 ;6>K JK9 JKI= ;I=E L7JK
BEBO &! * ($@*( +#, 5ut &t &! n+t +n t &! 5+@@($ 5+*#, t $#$ *#$ n+ t + B ! $#$%.
K#&t$ * p#+@#*' t *t #$*,! * p*&# + B+@@($ 5+*#,! *n, (&!t! *(( P&@E u +#,! t *t *#$ "+
5+t 5+*#,!.InputT $ &nput &($ &(( &n"(u,$ * $ ,*t* !$t!. E*" ,*t* !$t &(( 5$ * p*&# + 5+*#,! *! ! + n &n t $ !*'p($ &nput. A((&(( 5$ upp$# "*!$ ($tt$#!. T + "+n!$"ut&)$ $nt#&$! +n !*'$ 5+*#, &(( 5$ !$p*#*t$, 5- +n$ 5(*n?. T $ &#!t #+
5+*#, &(( 5$ +n t $ !*'$ (&n$ *! t $ &#!t #+ + t $ !$"+n, 5+*#,. T $- &(( 5$ !$p*#*t$, 5- +u# !p*"$!6 t $ !*'$ &+(, +# t $ #$'*&n&n@ 3 #+ !. B+*#, p*&#! &(( 5$ !$p*#*t$, 5- * 5(*n? (&n$. T $ &($ &(( 5$ t$#'&n*t$, 5- g? .
OutputF+# $*" p*&# + 5+@@($ 5+*#,!6 +utput *n *(p *5$t&"*((->!+#t$, (&!t + *(( "+''+n +#,!6 $*" +#, +n * !$p*#t $ !t*t$'$nt '4ere are no common words for t4is pair of bo le boards&
S$p*#*t$ t $ +utput +# $*" p*&# + 5+@@($ 5+*#,! &t * 5(*n? (&n$.
33
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 34/499
Sample Input= J J > 6 ; 7' 7 9 > 5 E 'K O M I 6 P 0 M > E K I 5
6 Q ; J 77 N C K 6 L J '
I ' 9 N 6 L P M > K K >
?
Sample Output'4ere are no common words for t4is pair of bo le boards&
6N K6K NN6KK6NN6KN K6K6NK N6
34
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 35/499
Un&)$#!&,*, ,$ Pu$#t+ R&"+ $n B*-*'7nD$p*#t*'$nt+ ,$ C&$n"&*! C+'put*,+#*!
A!+"&*"&7n ,$ E!tu,&*nt$! ,$ C&$n"&*! C+'put*,Categoría Principiante.nstrucciones generales
1. L$* ,$t$n&,*'$nt$ "*,* p#+5($'* - *!&@n$ $( +#,$n u$ p&$n!*n t#*5*0*#(+!.
2. L+! p#+5($'*! !$ ,$5$n $nt#$@*# !$@/n !$ )*n#$!+()&$n,+. N+ $!p$#$ *( &n*(.
3. I,$nt& & u$ $(diskette *!&@n*,+ "+n $( n+'5#$ ,$ !u p*#$0*.
4. A!$@/#$!$ ,$ u$ !$ p+n@* (* $" * $n (* +0* ,$!+(&"&tu, ,$ $)*(u*"&7n ,$( p#+5($'* - $( n+'5#$ p#+@#*'*.
. N: ut&(&"$ (* '&!'* +0* !& )* * )+()$# * !+'$t$#'&!'+ p#+5($'* ,$ nu$)+. U!$ +t#* +0* nu$)*.
:. D$5$ "#$*# - "+'p&(*# (+! p#+@#*'*! $n $(desktop ,$!u "+'put*,+#*. En $(diskette !7(+ )* * &n"(u&# $("7,&@+ ,$( p#+@#*'* u$ )* * !+'$t$#.
. A( &n*( #$"u$#,$ ,$)+()$#($ *( Hu$8 t+,*! (*! +u$ !$ ut&(&8*#+n p*#* !+'$t$# !u! p#+@#*'*!. *-u,* 'u" + *( '+'$nt+ ,$ ,$t$#'&n*# (*! p+!&"&+n$!.
3
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 36/499
-ines?eeperJ*)$ -+u $)$# p(*-$, M&n$! $$p$#h T &! "ut$ (&tt($ @*'$ "+'$! &t * "$#t*&n +p$#*t&n@ !-!t$' +!$ n*'$
#$'$'5$#. T $ @+*( + t $ @*'$ &! t+ &n, $#$ *(( t $ '&n$! *#$ (+"*t$, &t &n * x % &$(,.
T $ @*'$ ! + ! * nu'5$# &n * ! u*#$ &" t$((! -+u + '*n- '&n$! t $#$ *#$ *,0*"$nt t+ t *! u*#$. E*" ! u*#$ *! *t '+!t $&@ t *,0*"$nt ! u*#$!. T $ 4x 4 &$(, +n t $ ($ t "+nt*&n! t + '&n$$*" #$p#$!$nt$, 5- * gg. " *#*"t$#. I $ #$p#$!$nt t $ !*'$ &$(, 5- t $ &nt nu'5$#! ,$!"#&*5+)$6 $ $n, up &t t $ &$(, +n t $ #&@ t
.&&&&&&&&.&&
&&&&
.1!!221!1.1!111!
Input
T $ &nput &(( "+n!&!t + *n *#5&t#*#- nu'5$# + &$(,!. T $ &#!t (&n$ + $*" &$(, "+nt*&n *n, m < f n6m 1<<% &" !t*n, +# t $ nu'5$# + (&n$! *n, "+(u'n! + t $ &$(,6 #$!p$"t&)$E*" + t $ n$ t n (&n$! "+nt*&n! $ *"t(-m " *#*"t$#!6 #$p#$!$nt&n@ t $ &$(,.
S* $ ! u*#$! *#$ ,$n+t$, 5- gg& *n, '&n$ ! u*#$! 5- gg. 6 5+t &t +ut t $ u+t$!. T $ &#!t &$(, (&$#$ n Xm X < #$p#$!$nt! t $ $n, + &nput *n, ! +u(, n+t 5$ p#+"$!!$,.
Output
F+# $*" &$(,6 p#&nt t $ '$!!*@$Jield ? x : +n * (&n$ *(+n$6 $#$ & !t*n,! +# t $ nu'5$# + t $&$(, !t*#t&n@ #+' 1. T $ n$ tn (&n$! ! +u(, "+nt*&n t $ &$(, &t t $ gg& " *#*"t$#! #$p(*"$, 5- t $nu'5$# + '&n$! *,0*"$nt t+ t *t ! u*#$. T $#$ 'u!t 5$ *n $'pt- (&n$ 5$t $$n &$(, +utput!.
Fecha b'*-b2<< Nombre de la competencia S$ t*! C+'p$t$n"&*!Categoría P#&n"&p&*nt$ Universidad UPR> B*-*'7nAutor ACM Tipo de Competencia P#+@#*'*"&7nProblema 1
3:
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 37/499
Sample Input (File: mines eeper.in)$ $
.&&&&&&&&.&&&&&&3 "..&&&&&&&&&.&&&! !
Sample Output (File: mines eeper.out)Jield ?1:.1!!221!1.1!111!
Jield ?2:..1!!332!!1e1<<
3
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 38/499
@$RT U
A "+''+n t-p&n@ $##+# &! t+ p(*"$ -+u# *n,! +n t $ ?$-5+*#, +n$ #+ t+ t $ #&@ t + t $ "+# p+!&t&+n. T $n gg0 &! t-p$, *! gg *n, ggO &! t-p$, *! gg *n, !+ +n. Y+u# t*!? &! t+ ,$"+,$ *'$!!*@$ t-p$, &n t &! '*nn$#.
InputInput "+n!&!t! + !$)$#*( (&n$! + t$ t. E*" (&n$ '*- "+nt*&n ,&@&t!6 !p*"$!6 upp$#"*!$ ($tt$#! $ "$pt gg0 6 gg6 6 gg %6 +# pun"tu*t&+n ! + n *5+)$ Q$ "$pt 5*"?> u+t$ R% . $-! (*5$($, &t +#,! Q'ab 6>ac ;p 6Control 6 $t". *#$ n+t#$p#$!$nt$, &n t $ &nput.
OutputY+u *#$ t+ #$p(*"$ $*" ($tt$# +# pun"tu*t&+n !-'5+( 5- t $ +n$ &''$,&*t$(- t+ &t! ($ t +n t $ KERTY ?$-5+*#, *5+)$. Sp*"$! &n t $ &nput ! +u(, 5$ $" +$, &n t $ +utput.
Sample Input (Screen)K ;, KM5 IPJ;7
Sample Output (Screen)9 6M J9NE 'K=6I
Fecha b'*-b2<< Nombre de la competencia S$ t*! C+'p$t$n"&*!Categoría P#&n"&p&*nt$ Universidad UPR> B*-*'7nAutor ACM Tipo de Competencia P#+@#*'*"&7nProblema 2
3
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 39/499
!C>#isplayE!"#&5* un p#+@#*'* u$ pu$,* '+!t#*# ut&(&8*n,+ "*#*"t$#$!6 (+! ,`@&t+! nu' #&"+! u$ E!t+! ,`@&t+! ,$5$n '+!t#*#!$ $n +#'*t+ LCD !&'&(*# *( u$ 'u$!t#*n (*! "*("u(*,+#*!.
Input
S$ )* * ($$# ,$ un *#" &)+ ,$ )*#&*! (`n$*!. C*,* (`n$* )* * t$n$# ,+! n/'$#+! $nt$#+! !$p*un $!p*"&+. E( p#&'$# ,*t+ !% &n,&"* $( t*'*9+ !&8$% $n $( u$ ,$5$ !$# '+!t#*,+ $( n/'$ s i1<% - $( !$@un,+ ,*t+ n% &n,&"* $( n/'$#+ u$ !$ ,$!$* '+!t#*# < in i 6 6 %. L* /(t&'*(`n$* ,$ ,*t+! )* * t$n$# ,+! "$#+! < <% &n,&"*n,+ u$ n+ *- '_! n/'$#+! p*#* t#*5*0*#.
Output
Mu$!t#$ $n p*nt*((* (+! n/'$#+! $!p$"& &"*,+! $n $( *#" &)+ ,$ &nput $n +#'*t+ LCD ut@u&7n > % p*#* (+! !$@'$nt+! +#&8+nt*($! - $( j % p*#* (+! !$@'$nt+! )$#t&"*($!. C$ *"t*'$nt$ s 2 "+(u'n*! - 2 s 3 &(*!. D$5$ *5$# $ *"t*'$nt$ un* "+(u'n* ,$ 5(*n"+! $nt#$ ",+! ,`@&t+!.
D$5$ *5$# un* (`n$* $n 5(*n"+ $nt#$ "*,* n/'$#+. A "+nt&nu*"&7n !$ 'u$!t#* un $0$'p(+.
Sample Input
(File: LCdispla .in)
2 123$"3 *< B!! !
Fecha b'*-b2<< Nombre de la competencia S$ t*! C+'p$t$n"&*!Categoría P#&n"&p&*nt$ Universidad UPR> B*-*'7nAutor ACM Tipo de Competencia P#+@#*'*"&7nProblema 3
3
Sample Output
(File: LCdispla .out) DD DD DD
G G G G G GG G G G G G
DD DD DD DDG G G G G
G G G G G DD DD DD
DDD DDD DDD DDD DDDG G G G G G G GG G G G G G G GG G G G G G G G DDD DDD DDD
G G G G G G G GG G G G G G G GG G G G G G G G DDD DDD DDD DDD
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 40/499
Primary ArithmeticC &(,#$n *#$ t*u@ t t+ *,, 'u(t&>,&@&t nu'5$#! #+' #&@ t t+ ($ t6 +n$ ,&@&t *t * t&'$. Mgg"*##- +p$#*t&+n6 $#$ * 1 &! "*##&$, #+' +n$ ,&@&t p+!&t&+n t+ t $ n$ t6 t+ 5$ * !&" *(($n@$. Y+u# 0+5 &! t+ "+unt t $ nu'5$# + "*##- +p$#*t&+n! +# $*" + * !$t + *,,&t&+!+ t *t $,u"*t+#! '*- *!!$!! t $&# ,& &"u(t-.
InputE*" (&n$ + &nput "+nt*&n! t + un!&@n$, &nt$@$#! ($!! t *n 1< ,&@&t!. T $ (*!t (&n$ + &nput "+nt*&n! gg! ! .
OutputF+# $*" (&n$ + &nput $ "$pt t $ (*!t6 "+'put$ t $ nu'5$# + "*##- +p$#*t&+n! t *t #$!u(t #+' *,,&n@ t $ t + nu'5 p#&nt t $' &n t $ +#'*t ! + n 5$(+ .
Sample Input (File: primar .in)123 $"*""" """123 "B$! !
Sample Output (File: primar .out)No carry operation&3 carry operations&1 carry operation&
Fecha b'*-b2<< Nombre de la competencia S$ t*! C+'p$t$n"&*!Categoría P#&n"&p&*nt$ Universidad UPR> B*-*'7nAutor ACM Tipo de Competencia P#+@#*'*"&7nProblema 4
4<
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 41/499
Un&)$#!&,*, ,$ Pu$#t+ R&"+ $n B*-*'7nD$p*#t*'$nt+ ,$ C&$n"&*! C+'put*,+#*!
A!+"&*"&7n ,$ E!tu,&*nt$! ,$ C&$n"&*! C+'put*,
Categoría .ntermedio.nstrucciones generales
1. L$* ,$t$n&,*'$nt$ "*,* p#+5($'* - *!&@n$ $( +#,$n u$ p&$n!*n t#*5*0*#(+!.
2. L+! p#+5($'*! !$ ,$5$n $nt#$@*# !$@/n !$ )*n#$!+()&$n,+. N+ $!p$#$ *( &n*(.
3. I,$nt& & u$ $(diskette *!&@n*,+ "+n $( n+'5#$ ,$ !u p*#$0*.
4. A!$@/#$!$ ,$ u$ !$ p+n@* (* $" * $n (* +0* ,$!+(&"&tu, ,$ $)*(u*"&7n ,$( p#+5($'* - $( n+'5#$ p#+@#*'*.
. N: ut&(&"$ (* '&!'* +0* !& )* * )+()$# * !+'$t$#'&!'+ p#+5($'* ,$ nu$)+. U!$ +t#* +0* nu$)*.:. D$5$ "#$*# - "+'p&(*# (+! p#+@#*'*! $n $( ,$!?t+!u "+'put*,+#*. En $( ,&!?$tt$ !7(+ )* * &n"(u&#"7,&@+ ,$( p#+@#*'* u$ )* * !+'$t$#.
. A( &n*( #$"u$#,$ ,$)+()$#($ *( Hu$8 t+,*! (*! +u$ !$ ut&(&8*#+n p*#* !+'$t$# !u! p#+@#*'*!.
*-u,* 'u" + *( '+'$nt+ ,$ ,$t$#'&n*# (*! p+!&"&+n$!.
41
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 42/499
(e)erse an* &**
T $ re'erse and add un"t&+n !t*#t! &t * nu'5$#6 #$)$#!$! &t! ,&@&t! *n, *,,! t $ #$)$#!$ t+ +#&@&n*(. I t $ !u' &! n+t * p*(&n,#+'$ '$*n&n@ &t ,+$! n+t @&)$ t $ !*'$ nu'5$# #$*, #+#&@ t *n, #&@ t t+ ($ t%6 $ #$p$*t t &! p#+"$,u#$ unt&( &t ,+$!.
F+# $ *'p($6 & $ !t*#t &t 1 *! t $ &n&t&*( nu'5$#6 $ @$t 633 *! t $ #$!u(t&n@ p*(&n,#t $ +u#t *,,&t&+n
T &! '$t +, ($*,! t+ p*(&n,#+'$! &n * $ !t$p! +# *('+!t *(( +t $ &nt$@$#!. But t $#$ *#$ &nt$#$!t&n@ $ "$pt&+n!. 1 : &! t $ &#!tnu'5$# +# &" n+ p*(&n,#+'$ *! 5$$n +un,. It *! n$)$# 5$$n p#+)$n6 + $)$#6 t *t n+ !u" p*(&n,#+'$ $ &!t!.
Y+u 'u!t #&t$ * p#+@#*' t *t t*?$! * @&)$n nu'5$# *n, @&)$! t $ #$!u(t&n@ p*(&n,#+'$ &*n, t $ nu'5$# + &t$#*t&+n!b*,,&t&+n! &t t++? t+ &n, &t.
Y+u '*- *!!u'$ t *t *(( t $ nu'5$#! u!$, *! t$!t ,*t* &(( t$#'&n*t$ &n *n *n! $# &t ($!! t *n 16<&t$#*t&+n! *,,&t&+n!%6 *n, -&$(, * p*(&n,#+'$ t *t &! n+t @#$*t$# t *n 462 46 : 62 .InputT $ &#!t (&n$ &(( "+nt*&n *n &nt$@$# % < f % 1<<%6 @&)&n@ t $ nu'5$# + t$!t "*!$!6 &($ t $ n$ t % (&n$! $*" "+nt*&n!&n@($ &nt$@$# +!$ p*(&n,#+'$ -+u *#$ t+ "+'put$.
OutputF+# $*" + t $ % &nt$@$#!6 p#&nt * (&n$ @&)&n@ t $ '&n&'u' nu'5$# + &t$#*t&+n! t+ &n, t $ p*(&n,#+'$6 *t $n t $ #$!u(t&n@ p*(&n,#+'$ &t!$( .
Sample Input (File: reverse.in)31B"2*"<"!
Sample Output (File: reverse.out)$ B33B" $"2"$3 ****
Fecha b'*-b2<< Nombre de la competencia S$ t*! C+'p$t$n"&*!Categoría Int$#'$,&+ Universidad UPR> B*-*'7nAutor ACM Tipo de Competencia P#+@#*'*"&7nProblema 1
1 : 164 3 62141 : 36 41 4612
>>> >>> >>> >>>: 164 3 6214 633
42
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 43/499
@here s @aldor7
G&)$n *nm 5- n @#&, + ($tt$#! *n, * (&!t + +#,!6 &n, t $ (+"*t&+n &n t $ @#&, *t &" t $ 5$ +un,.
A +#, '*t" $! * !t#*&@ t6 un&nt$##upt$, (&n$ + ($tt$#! &n t $ @#&,. A +#, "*n '*t" t $ ($tt@#&, #$@*#,($!! + "*!$ &.$.6 upp$#> *n, (+ $#"*!$ ($tt$#! *#$ t+ 5$ t#$*t$, *! t $ !*'$%. T"*n 5$ ,+n$ &n *n- + t $ $&@ t +#&8+nt*(6 )$#t&"*(6 +# ,&*@+n*( ,&#$"t&+n! t #+u@ t
Input
T $ &nput 5$@&n! &t * !&n@($ p+!&t&)$ &nt$@$# +n * (&n$ 5- &t!$( &n,&"*t&n@ t $
+((+ $, 5- * 5(*n? (&n$. T $#$ &! *(!+ * 5(*n? (&n$ 5$t $$n $*" t + "+n!$"ut&)$ "*!$!.
E*" "*!$ 5$@&n! &t * p*&# + &nt$@$#!m +((+ $, 5- n +n * !&n@($ (&n$6 $#$ 1m6n < &n,$"&'*( n+t*t&+n. T $ n$ tm (&n$! "+nt*&nn ($tt$#! $*" 6 #$p#$!$nt&n@ t $ @#&, + ($tt$#! $#$+#,! 'u!t 5$ +un,. T $ ($tt$#! &n t $ @#&, '*- 5$ &n upp$#> +# (+ $#"*!$. F+((+ &n@ t $ @#($tt$#!6 *n+t $# &nt$@$#k *pp$*#! +n * (&n$ 5- &t!$( 1k 2<%. T $ n$ tk (&n$! + &nput "+nt*&n (&!t + +#,! t+ !$*#" +#6 +n$ +#, p$# (&n$. T $!$ +#,! '*- "+nt*&n upp$#> *n, (+ $#"*!$ ($+n(- > n+ !p*"$!6 -p $n!6 +# +t $# n+n>*(p *5$t&" " *#*"t$#!.
Output
F+# $*" +#, &n $*" t$!t "*!$6 +utput * p*&# + &nt$@$#! #$p#$!$nt&n@ &t! (+"*t&+n &@#&,. T $ &nt$@$#! 'u!t 5$ !$p*#*t$, 5- * !&n@($ !p*"$. T $ &#!t &nt$@$# &! t $ (&n$ &&#!t ($tt$# + t $ @&)$n +#, "*n 5$ +un, 1 #$p#$!$nt! t $ t+p'+!t (&n$ &n t $ @#&,6 *n,m #$p#$!$nt!t $ 5+tt+''+!t (&n$%. T $ !$"+n, &nt$@$# &! t $ "+(u'n &n t $ @#&, $#$ t $ &#!t ($tt$# + t+#, "*n 5$ +un, 1 #$p#$!$nt! t $ ($ t'+!t "+(u'n &n t $ @#&,6 *n,n #$p#$!$nt! t $ #&@ t'+!t"+(u'n &n t $ @#&,%. I * +#, "*n 5$ +un, '+#$ t *n +n"$ &n t $ @#&,6 t $n +utput t $ (+"*t&upp$#'+!t +""u##$n"$ + t $ +#, &.$.6 t $ +""u##$n"$ &" p(*"$! t $ &#!t ($tt$# + t $ +#, "t+ t $ t+p + t $ @#&,%. I t + +# '+#$ +#,! *#$ upp$#'+!t6 +utput t $ ($ t'+!t + t $!$ +""u##$nA(( +#,! "*n 5$ +un, *t ($*!t +n"$ &n t $ @#&,.
T $ +utput + t + "+n!$"ut&)$ "*!$! 'u!t 5$ !$p*#*t$, 5- * 5(*n? (&n$.
Fecha b'*-b2<< Nombre de la competencia S$ t*! C+'p$t$n"&*!Categoría Int$#'$,&+ Universidad UPR> B*-*'7nAutor ACM Tipo de Competencia P#+@#*'*"&7nProblema 2
43
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 44/499
Sample Input (File: aldorf.in)1
11abc=EJ 4i4Eb al=orJty6waldK5mJtsimr src
byo6r>e=eyvlcb wi omstrE> ad4rby7i lxcn>8f$aldorf>ambi>etty=a bert
Sample Output (File: aldorf.out)2 "2 31 2<
44
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 45/499
0ummation o7 Four PrimesK*#&n@ ! p#&'$ nu'5$# "+n0$"tu#$ !t*t$! t *t $)$#- +,, &nt$@$# &! $&t $# p#&'$ +# t $ !u' p#&'$!. G+(,5*" ! "+n0$"tu#$ &! t *t $)$#- $)$n &nt$@$# &! t $ !u' + t + p#&'$!. B+t p#+5( 5$$n +p$n +# +)$# 2<< -$*#!.
In t &! p#+5($' -+u *)$ * !(&@ t(- ($!! ,$'*n,&n@ t*!?. F&n, * *- t+ $ p#$!! * @&)$n &nt$@!u' + $ *"t(- +u# p#&'$!.
Input
E*" &nput "*!$ "+n!&!t! + +n$ &nt$@$#n n 1<<<<<<<% +n &t! + n (&n$. Input &! t$#'&n*t$, 5&($.
Output
F+# $*" &nput "*!$n6 p#&nt +n$ (&n$ + +utput "+nt*&n&n@ +u# p#&'$ nu'5$#! &" !u' up n. I t $nu'5$# "*nn+t 5$ $ p#$!!$, *! * !u''*t&+n + +u# p#&'$ nu'5$#! p#&nt t $ (&n$ gg9mpossible& &n *!&n@($ (&n$. T $#$ "*n 5$ 'u(t&p($ !+(ut&+n!. An- @++, !+(ut&+n &(( 5$ *""$pt$,.
Sample Input (File: fourprimes.in)2$
3*$*
Sample Output (File: fourprimes.out)3 11 3 <3 < 13 1311 11 1< <
Fecha b'*-b2<< Nombre de la competencia S$ t*! C+'p$t$n"&*!Categoría Int$#'$,&+ Universidad UPR> B*-*'7nAutor ACM Tipo de Competencia P#+@#*'*"&7nProblema 3
4
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 46/499
Ant on a Chessboard
On$ ,*-6 *n *nt n*'$, A(&"$ "*'$ up+n *n x " $!!5+*#,. S $ *nt$, t+ $ p(+#$ *(( t $ "$((! +t $ 5+*#,. S+ ! $ 5$@*n t+ *(? *(+n@ t $ 5+*#, 5- p$$(&n@ + * "+#n$# + t $ 5+*#,.
A(&"$ !t*#t$, *t ! u*#$ 16 1%. F&#!t6 ! $ $nt up +# * !t$p6 t $n * !t$p t+ t $ #&@ t6 *n, * !t,+ n *#,. A t$# t *t6 ! $ $nt * !t$p t+ t $ #&@ t6 t $n t + !t$p! up *#,6 *n, t $n t + @#&,! t+ t $($ t. In $*" #+un,6 ! $ *,,$, +n$ n$ #+ *n, +n$ n$ "+(u'n t+ t $ "+#n$# ! $ *, $ p(+#$,.
F+# $ *'p($6 $# &#!t 2 !t$p! $nt (&?$ t &!6 $#$ t $ nu'5$#! &n $*" ! u*#$ ,$n+t$ +n &" ! $ )&!&t$, &t.
2 24 23 22 21
1< 11 12 13 2< 14 12 3 : 1 11 4 1: 1
J$# t !t$p put $# +n ! u*#$ 26 3%6 &($ $# 2<t !t$p put $# +n ! u*#$ 6 4%. Y+u# t*!? &,$"&,$ $#$ ! $ *! *t * @&)$n t&'$6 *!!u'&n@ t $ " $!!5+*#, &! (*#@$ $n+u@ t+ *""$pt *(('+)$'$nt!.Input
T $ &nput &($ &(( "+nt*&n !$)$#*( (&n$!6 $*" &t *n &nt$@$# % ,$n+t&n@ t $ !t$p nu'5$# $#$ 1 % 2 x 1<. T $ &($&(( t$#'&n*t$ &t * (&n$ t *t "+nt*&n! t $ nu'5$#! .
OutputF+# $*" &nput !&tu*t&+n6 p#&nt * (&n$ &t t + nu'5$#! &6 y% ,$n+t&n@ t $ "+(u'n *n, t $ #+ nu'5$##$!p$"t&)$(-. T $#$ 'u!t 5$ * !&n@($ !p*"$ 5$t $$n t $'.Sample Input (File: ant.in)
2!2"!
Sample Output (File: ant.out)2 3" $1 "
Fecha b'*-b2<< Nombre de la competencia S$ t*! C+'p$t$n"&*!Categoría Int$#'$,&+ Universidad UPR> B*-*'7nAutor ACM Tipo de Competencia P#+@#*'*"&7nProblema 4
4:
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 47/499
Un&)$#!&,*, ,$ Pu$#t+ R&"+ $n B*-*'7nD$p*#t*'$nt+ ,$ C&$n"&*! C+'put*,+#*!
A!+"&*"&7n ,$ E!tu,&*nt$! ,$ C&$n"&*! C+'put*,
Categoría $5perto.nstrucciones generales
1. L$* ,$t$n&,*'$nt$ "*,* p#+5($'* - *!&@n$ $( +#,$n u$ p&$n!*n t#*5*0*#(+!.
2. L+! p#+5($'*! !$ ,$5$n $nt#$@*# !$@/n !$ )*n#$!+()&$n,+. N+ $!p$#$ *( &n*(.
3. I,$nt& & u$ $(diskette *!&@n*,+ "+n $( n+'5#$ ,$ !u p*#$0*.
4. A!$@/#$!$ ,$ u$ !$ p+n@* (* $" * $n (* +0* ,$!+(&"&tu, ,$ $)*(u*"&7n ,$( p#+5($'* - $( n+'5#$ p#+@#*'*.
. N: ut&(&"$ (* '&!'* +0* !& )* * )+()$# * !+'$t$#'&!'+ p#+5($'* ,$ nu$)+. U!$ +t#* +0* nu$)*.:. D$5$ "#$*# - "+'p&(*# (+! p#+@#*'*! $n $( ,$!?t+!u "+'put*,+#*. En $( ,&!?$tt$ !7(+ )* * &n"(u&#"7,&@+ ,$( p#+@#*'* u$ )* * !+'$t$#.
. A( &n*( #$"u$#,$ ,$)+()$#($ *( Hu$8 t+,*! (*! +u$ !$ ut&(&8*#+n p*#* !+'$t$# !u! p#+@#*'*!.
*-u,* 'u" + *( '+'$nt+ ,$ ,$t$#'&n*# (*! p+!&"&+n$!.
4
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 48/499
FmtT $ UNI; p#+@#*' fmt #$*,! (&n$! + t$ t6 "+'5&n&n@ *n, 5#$*?&n@ t $' !+ *! t+ "#$*t$ *n +&t (&n$! *! "(+!$ t+ 2 " *#*"t$#! (+n@ *! p+!!&5($ &t +ut $ "$$,&n@ t &! (&'&t. T $ #u($"+'5&n&n@ *n, 5#$*?&n@ (&n$! *#$ *! +((+ !
• A n$ (&n$ '*- 5$ !t*#t$, *n- $#$ t $#$ &! * !p*"$ &n t $ &nput. K $n * n$ (&n$ &! !t*#t$,6 5(*n?! *t t $t $ p#$)&+u! (&n$ *n, *t t $ 5$@&nn&n@ + t $ n$ (&n$ *#$ $(&'&n*t$,.
• A (&n$ 5#$*? &n t $ &nput '*- 5$ $(&'&n*t$, &n t $ +utput un($!! 1% &t &! *t t $ $n, + * 5(*n? +# $'pt&t &! +((+ $, 5- * !p*"$ +# *n+t $# (&n$ 5#$*?. K $n * (&n$ 5#$*? &! $(&'&n*t$,6 &t &! #$p(*"$, 5- *
• Sp*"$! 'u!t 5$ #$'+)$, #+' t $ $n, + $*" +utput (&n$.• An- &nput +#, "+nt*&n&n@ '+#$ t *n 2 " *#*"t$#! 'u!t *pp$*# +n *n +utput (&n$ 5- &t!$( .
Y+u '*- *!!u'$ t *t t $ &nput t$ t ,+$! n+t "+nt*&n *n- t*55&n@ " *#*"t$#!.
Sample Input (File: fmt.in) 7nix fmt
'4e unix fmt pro ram reads lines of text, combininand brea in lines so as to create anoutput file wit4 lines as close to wit4out exceedin<2 c4aracters lon as possible& '4e rules for combinin and brea inlines are as follows&
1& 6 new line may be started anyw4ere t4ere is a space in t4e input&9f a new line is started, t4ere will be no trailin blan s at t4eend of t4e previous line or at t4e be innin of t4e new line&
2& 6 line brea in t4e input may be eliminated in t4e output, providedit is not followed by a space or anot4er line brea & 9f a linebrea is eliminated, it is replaced by a space&
Fecha b'*-b2<< Nombre de la competencia S$ t*! C+'p$t$n"&*!Categoría E;PERTO Universidad UPR> B*-*'7nAutor ACM Tipo de Competencia P#+@#*'*"&7nProblema 1
4
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 49/499
Sample Output (File: fmt.out) 7nix fmt
'4e unix fmt pro ram reads lines of text, combinin and brea in linesso as to create an output file wit4 lines as close to wit4out exceedin<2 c4aracters lon as possible& '4e rules for combinin and brea inlines are as follows&
1& 6 new line may be started anyw4ere t4ere is a space in t4e input&9f a new line is started, t4ere will be no trailin blan s at t4e end oft4e previous line or at t4e be innin of t4e new line&
2& 6 line brea in t4e input may be eliminated in t4e output,provided it is not followed by a space or anot4er line brea & 9f a linebrea is eliminated, it is replaced by a space&
4
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 50/499
Calculator !anguage
C*("u(*t+# L*n@u*@$ CL% !upp+#t! *!!&@n'$nt6 p+!&t&)$ *n, n$@*t&)$ &nt$@$#! *n,T $ *((+ *5($ " *#*"t$#! &n * CL !t*t$'$nt *#$ t u!
A(( +p$#*t+#! *)$ t $ !*'$ p#$"$,$n"$ *n, *#$ #&@ t *!!+"&*t&)$6 t u! 1 > > 3 X 1 > > 3+n$ +u(, $ p$"t6 5#*"?$t! &(( +#"$ t $ $ p#$!!&+n &t &n t $' t+ 5$ $)*(u*t$, &#!t. B#*"?$t 5$ n$!t$, *#5&t#*#&(- ,$$p(-. An $ p#$!!&+n n$)$# *! t + +p$#*t+#! n$ t t+ $*" +t $# $)$n!$p*#*t$, 5- * 5#*"?$t%6 *n *!!&@n'$nt +p$#*t+# &! *( *-! &''$,&*t$(- p#$"$,$, 5- * )*#&*($ t'+!t +p$#*t+# +n * (&n$ &! *( *-! *n *!!&@n'$nt. F+# #$*,*5&(&t-6 !p*"$! '*- 5$ #$$(- &*n $ p#$!!&+n6 $ "$pt 5$t $$n * n$@*t&)$ !&@n *n, * nu'5$#. A n$@*t&)$ !&@n &(( n+t )*#&*5($. A(( )*#&*5($! *#$ &n&t&*(&!$, t+ 8$#+ <% *n, #$t*&n t $&# )*(u$! unt&( " *n
K#&t$ * p#+@#*' t *t &(( *""$pt *n, $)*(u*t$ $ p#$!!&+n! #&tt$n &n t &! (*n@u*@$. E*"+""up&$! +n$ (&n$ *n, "+nt*&n! *t ($*!t +n$ *!!&@n'$nt +p$#*t+#6 *n, '*-5$ '+#$.
Input
Input &(( "+n!&!t + * !$#&$! + (&n$!6 $*" (&n$ "+nt*&n&n@ * "+##$"t CL $ p#$!!&+n. (+n@$# t *n 1<< " *#*"t$#!. T $ &($ &(( 5$ t$#'&n*t$, 5- * (&n$ "+n!&!t&n@ + * !&n@($? .
Fecha b'*-b2<< Nombre de la competencia S$ t*! C+'p$t$n"&*!Categoría E;PERTO Universidad UPR> B*-*'7nAutor ACM Tipo de Competencia P#+@#*'*"&7nProblema 2
<
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 51/499
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 52/499
Chec3 the Chec3 Y+u# t*!? &! t+ #&t$ * p#+@#*' t *t #$*,! * " $!!5+*#, "+n &@u#*t&+n *n, &,$nt& &$! $tun,$# *tt*"? &n " $"?%. A ?&n@ &! &n " $"? & &t &! +n ! u*#$ &" "*n 5$ t*?$n 5- t $ +pn$ t '+)$.
K &t$ p&$"$! &(( 5$ #$p#$!$nt$, 5- upp$#"*!$ ($tt$#!6 *n, 5(*"? p&$"$! 5- (+ $#"*!$ ($tt$#!&,$ &(( *( *-! 5$ +n t $ 5+tt+' + t $ 5+*#,6 &t t $ 5(*"? !&,$ *( *-! +n t $ t+p.
F+# t +!$ un *'&(&*# &t " $!!6 $#$ *#$ t $ '+)$'$nt! + $*" p&$"$
Pa?n 2 p or +6( "*n +n(- '+)$ !t#*&@ t * $*,6 +n$ ! u*#$ *t * t&'$. J+ $)$#6 &t t*?$! p&$"$! ,&*@+n*((-6 *n, t *t &! *-+u &n t &! p#+5($'.
Dnight 2n or , 6 *! *n L>! *p$, '+)$'$nt ! + n 5$(+ . It &! t $ +n(- p&$"$ t *t "*n 0u'p +)$# +t $# p&$"$!.
Bishop 2 b or 6 "*n '+)$ *n- nu'5$# + ! u*#$! ,&*@+n*((-6 $&t $# +# *#, +# 5*"? *#,.
Roo3 2r or ( 6 "*n '+)$ *n- nu'5$# + ! u*#$! )$#t&"*((- +# +#&8+nt*((-6 $&t $# +# *#, +# 5*"? *#,.
Eueen 2% or 6 "*n '+)$ *n- nu'5$# + ! u*#$! &n *n- ,&#$"t&+n ,&*@+n*((-6 +#&8+nt*((-6 +# )$#t&"*((-% $&t $#
5*"? *#,.
Ding 2k or 6 "*n '+)$ +n$ ! u*#$ *t * t&'$ &n *n- ,&#$"t&+n ,&*@+n*((-6 +#&8+nt*((-6 +# )$#t&"*((-% $&t $# + 5*"? *#,.
M+)$'$nt $ *'p($! *#$ ! + n 5$(+ 6 $#$ gg . &n,&"*t$! t $ p+!&t&+n! $#$ t $ p&$"$
"*n "*ptu#$ *n+t $# p&$"$
Fecha b'*-b2<< Nombre de la competencia S$ t*! C+'p$t$n"&*!Categoría E;PERTO Universidad UPR> B*-*'7nAutor ACM Tipo de Competencia P#+@#*'*"&7nProblema 3
2
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 53/499
Pawn 5oo >is4op 0ueen in ni 4t &&&&&&&& &&&.&&&& &&&&&&&. &&&.&&&. &&&&&&&& &&&&&&&& &&&&&&&& &&&.&&&& .&&&&&.& .&&.&&.& &&&&&&&& &&&&&&&& &&&&&&&& &&&.&&&& &.&&&.&& &.&.&.&& &&&&&&&& &&.&.&&& &&&&&&&& &&&.&&&& &&.&.&&& &&...&&& &&...&&& &.&&&.&& &&&p&&&& ...r.... &&&b&&&& ... .... &&. .&&& &&&n&&&& &&.&.&&& &&&.&&&& &&.&.&&& &&...&&& &&...&&& &.&&&.&& &&&&&&&& &&&.&&&& &.&&&.&& &.&.&.&& &&&&&&&& &&.&.&&& &&&&&&&& &&&.&&&& .&&&&&.& .&&.&&.& &&&&&&&& &&&&&&&&
R$'$'5$# t *t t $ ?n&@ t &! t $ +n(- p&$"$ t *t "*n 0u'p +)$# +t $# p&$"$!. T $ p* n '+)$'$nt &,$p$n, +n &t! !&,$. I &t &! * 5(*"? p* n6 &t "*n +n(- '+)$ +n$ ! u*#$ ,&*@+n*((- ,+ n t $ 5+* &t$ p* n6 &t "*n +n(- '+)$ +n$ ! u*#$ ,&*@+n*((- up t $ 5+*#,. T $ $ *'p($ *5+)$ &! * 5(* p* n6 ,$!"#&5$, 5- * (+ $#"*!$ ggp . K$ u!$ ggmo'e t+ &n,&"*t$ t $ ! u*#$! $#$ t $ p* n "*n"*ptu#$ *n+t $# p&$"$.
Input
T $#$ &(( 5$ *n *#5&t#*#- nu'5$# + 5+*#, "+n &@u#*t&+n! &n t $ &nput6 $*" "+n!&!t&n$&@ t " *#*"t$#! $*" . A gg& ,$n+t$! *n $'pt- ! u*#$6 &($ upp$#> *n, (+ $#"*!$ ($tt$#! #$p#$!$ p&$"$! *! ,$ &n$, *5+)$. T $#$ &(( 5$ n+ &n)*(&, " *#*"t$#! *n, n+ "+n &@u#*t&+n! $#$*#$ &n " $"?. Y+u 'u!t #$*, unt&( -+u &n, *n $'pt- 5+*#, "+n!&!t&n@ +n(- + gg& " *#*"t$#!6 &"! +u(, n+t 5$ p#+"$!!$,. T $#$ &(( 5$ *n $'pt- (&n$ 5$t $$n $*" p*&# + 5+*#, "+n &@u#*t& 5+*#,!6 $ "$pt +# t $ $'pt- +n$6 &(( "+nt*&n $ *"t(- +n$ &t$ ?&n@ *n, +n$ 5(*"? ?&n@.
Output
F+# $*" 5+*#, "+n &@u#*t&+n #$*, -+u 'u!t +utput +n$ + t $ +((+ &n@ *n! $#!
ame ? d : w4ite in is in c4ec &
ame ? d : blac in is in c4ec &
ame ? d : no in is in c4ec &
$#$ d !t*n,! +# t $ @*'$ nu'5$# !t*#t&n@ #+' 1.
3
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 54/499
Sample Input (File: c*ec$.in)&& &&&&&ppp&pppp
&&&&&&&&&5&&&>&&&&&&&&&&&&&&&&&&PPPPPPPP&&&&&&&
rnb &nrppp&&ppp&&&&p&&&&&&p&&&&&bPP&&&&&&&&&N&&PP&&PPPP5N>0 >&5
&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
Sample Output (File: c*ec$.out)ame ?1: blac in is in c4ec &ame ?2: w4ite in is in c4ec &
4
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 55/499
0E! 0.-U!AT:R N+ "#$+ u$ t$n@* u$ $ p(&"*# * $!t$ n&)$( (+ u$ $! S L - !u u!+ $n (*! B*!$! ,$ D*t+!. V*"#$*# un !&'u(*,+# ,$( "+'*n,+ SELECT ,$ un* *p(&"*"&7n ,$ B*!$ ,$ D*t+! "+'+ (+ $! O#*"$0$'p(+. E( +#'*t+ ,$( SELECT !$n"&((+ u$ )*'+! * ut&(&8*# p*#* "#$*# $!t* !&'u(*"&7n!&@u&$nt$
" atributos( M entidad
7 ( condici@n( ( atributoT
S7(+ )*'+! * t#*5*0*# "+n un* t*5(* - (*! p+!&5($! "+'5&n*"&+n$! !+n (*! !&@u&$nt$!
'. "
0$!$CT e0$!$CT *t#&5ut+l1
0$!$CT *t#&5ut+l16 *t#&5ut+l26 *t#&5ut+ln
''. ( M
FR:- $nt&,*,
'''. 7 (
@;$R$ *t#&5ut+ m X j Zj f j ZX j fX j WX m "+n!t*nt$ j !t#&n@ QmAND j OR "+n,&t
':. ( ( :R#$R B *t#&5ut+ QASC j DESC a
Fecha b'*-b2<< Nombre de la competencia S$ t*! C+'p$t$n"&*!Categoría E;PERTO Universidad UPR> B*-*'7nAutor N$((&u, D. T+##$! Tipo de Competencia P#+@#*'*"&7nProblema 4
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 56/499
InputL* t*5(* !$ )* * "*#@*# ,$ un *#" &)+ !$"u$n"&*( - )* * t$n$# $( !&@u&$nt$ +#'*t+
nombre de la tabla
atributoS1, atributoS2,U atributoSn
tipo de datoD1, tipo de datoD2, U tipo de datoDn
valorS1, valorS2,U valorSn,
! !
1. En (* p#&'$#* (`n$* )* * $!t*# $( n+'5#$ ,$ (* t*5(* !&n $!p*"&+! $n 5(*n"+.
2. L* !$@un,* (`n$* $!t*#_ $n 5(*n"+.
3. L* t$#"$#* (`n$* )* * t$n$# (+! n+'5#$! ,$ (+! *t#&5ut+!.
4. L* "u*#t* (̀ n$* $!t*#_ $n 5(*n"+.
"& L* u&nt* (`n$* )* * &n,&"*# $( t&p+ ,$ ,*t+. ; X *( *nu' #&"+ strin# %6 X nu' #&"+ $nt$#+6
X nu' #&"+ #$*(
:. L* !$ t* (`n$* $!t*#_ $n 5(*n"+.
. D$ (* ! pt&'* (`n$* $n *,$(*nt$ !$ $n"u$nt#*n (+! ,*t+!.
. L* /(t&'* (`n$* )* * t$n$# ,+! "$#+! <% !$p*#*,+! p+# un $!p*"&+ $n 5(*n"+. E!t+ n+
&n,&"*# u$ $! $( &n*( ,$ (* t*5(*.
L+! "+'*n,+! ,$ S L !$ p&,$n p+# p*nt*((*. Pu$,$n t$n$# '_! ,$ un* (̀ n$* - n+ !$ pu$,$0$"ut*# *!t* $n"+nt#*# $( punt+ - "+'* a%. S$ t&$n$ u$ )*(&,*# (*! !&nt* &! ,$ (*! &n!t#n+'5#$! ,$ (+! *t#&5ut+! - t*5(*. E( #$!u(t*,+ !$ 'u$!t#* &nt$#*"t&)*'$nt$ $n p*nt*((*.
OutputS$ )* * '+!t#*# (+! #$!u(t*,+! ,$( S L $n p*nt*((*. T*'5& n ,$5$n !*(&# (+! '$n!*0$! ,$ $##+#$n"*5$8*'&$nt+! u$ !$ )*n * '+!t#*# $n (+! $0$'p(+!.
:
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 57/499
Sample Input (File: s+l.in)estudiante
nombre, numeroSestudiante, edad, enero, promedio
x, x, B, x, v
acarias Piedras =el 5io, 123D$"D*< B, 1B, M, 3&3$Pepito ;anto Cielo, B <D*"D$321, 22, M, 2& 1Ouana a oca, 1*3D$"D< 23, 21, J, $&!!Oose 9van 6lcara, B$"D23D$"*2, 1<, M, 1&*BMin uita omeH, "2<D 3D"B12, 2 , J, 2&"$! !
Sample Output (Screen)
; ;E EC' . J5KM estudianteT
; ;E EC' nombre, edad, enero J5KM estudianteT
; ;E EC' nombre, edd, enero; J5KM estudianteT
... 6tributo invalido VeddW ...
nombre numeroSestudiante edad enero promedio DDDDDDDD DDDDDDDDDDDDDDDDD DDDD DDDDDD DDDDDDDDacarias Piedras =el 5io 123D$"D*< B 1B M 3&3$Pepito ;anto Cielo B <D*"D$321 22 M 2& 1Ouana a oca 1*3D$"D< 23 21 J $&!!Oose 9van 6lcara B$"D23D$"*2 1< M 1&*BMin uita omeH "2<D 3D"B12 2 J 2&"$
nombre edad eneroDDDDDDDD DDDD DDDDDD
acarias Piedras =el 5io 1B MPepito ;anto Cielo 22 MOuana a oca 21 JOose 9van 6lcara 1< MMin uita omeH 2 J
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 58/499
; ;E EC' nombre, edad, enero; J5KM estudiant; T
... 'abla invalida VestudiantW ...
; ;E EC' nombre, edad, enero J5KM estudiante; LE5E edad W% 21T
; ;E EC' nombre, edad, enero J5KM estudiante; LE5E edad W% 21; K5=E5 >I nombre 6;CT
; ;E EC' nombre, promedio J5KM estudiante; K5=E5 >I promedio 6;CT
nombre edad eneroDDDDDDDD DDDD DDDDDD
Pepito ;anto Cielo 22 MOuana a oca 21 JMin uita omeH 2 J
nombre edad eneroDDDDDDDD DDDD DDDDDD
Ouana a oca 21 JMin uita omeH 2 JP$p&t+ S*nt+ C&$(+ 22 M
nombre promedio DDDDDDDD DDDDDDDDOose 9van 6lcara 1&*B
Min uita omeH 2&"$Pepito ;anto Cielo 2& 1acarias Piedras =el 5io 3&3$Ouana a oca $&!!
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 59/499
Impor!ador de da!o" de"de CO#O$ alSolon Da!aba"e Managemen! S%"!em &SD#MS'
S$ ($ * $n"+'$n,*,+ (* t*#$* ,$ "+n!t#u&# un p#+@#*'* u$ &'p+#t$ ,*t+! ,$ un !&!t$'* ,$ *#" &)+!le#acy '*n$0*,+ p+#COBOL * un !&!t$'* ,$ 5*!$ ,$ ,*t+! ((*'*,+ SDBM>>>>>>>>>>>>>>>>>>>>>S. E( p#+@#*'* u$ &'p+#t* (+!$nt#*,* un *#" &)+ $n ;ML ,$ (* !&@u&$nt$ '*n$#*
V xml versi@n%X!&!1alp4aX encodin %X7'JD X WV;c4emaDJormatWV6lp4anumericW3!VA6lp4anumericWVNumberW VANumberWVNumberW &2VANumberWV=ateWyyyymmddVA=ateWVA;c4emaDJormatWVAxmlW
SDBMS !+(+ '*n$0* 3 t&p+! ,$ ,*t+! 1% A( *nu' #&"+6 2% N/'$#+! - 3% F$" *!. N+t$ u$ $nt#$'$,&+ ,$ (*! $tta#s % ,$ ;ML !$ $n"u$nt#* (+!descriptores ,$ (+! t&p+! ,$ ,*t+!.
A( *nu' #&"+ !+(+ pu$,$ (($)*# un n/'$#+ $nt$#+ $nt#$ *'5*! $t& u$t*! - $!t$ n/'$#+ &n,&"* (* "*nt&,*, ,$ $!p*"SDBMS $!p$#* @u*#,*# $n (* 5*!$ ,$ ,*t+! F*)+# )$# $( $0$'p(+%. S& $( *#" &)+ u$ !$ &'p+#t* ,$ COBOL t$( n/'$#+ &n,&"*,+ $!t+! "*#*"t$#$! n+ !$ ($$n6 $! ,$" !+(+ !$ @u*#,*n (+! "*#*"t$#$! &n,&"*,+! $n (* 5*!!&!t$'* ,$5$ #$p+#t*# (* "*nt&,*, ,$ "*#*"t$#$! u$ n+ &n"(u-+ $n (* &'p+#t*"&7n.
L* $t& u$t* p*#* $( n/'$#+ !+(+ (($)* $nt#$'$,&+ un )*(+# u$ &n,&"* (* "*nt&,*, ,$ $!p*"&+! #$!$#)*,+! p*#*
)*(+# nu' #&"+. En $( $0$'p(+ fNu'5$#Z fbNu'5$#Z !&@n& &"* un $nt$#+ ,$ un '_ &'+ ,$ $!p*"&+!.fNu'5$#Z .2fbNu'5$#Z !&@n& &"* un n/'$#+ #$*( "+n un '_ &'+ ,$ $!p*"&+! - 2 ,$"&'*($!.#e encontrar un valorno num rico donde se supone Gue e5ista uno el sistema emitir* un errorHE( $!p*"&+ '_ &'+ u$ pu$,$ *5$##$!$#)*,+ !+n 12 $!p*"&+! p*#* (+! $nt$#+! - : p*#* (+! ,$"&'*($!. D$ *5$#!$ !+5#$p*!*,+ ,$ $!t+! (&'&t$! $( !&n,&"*#* $( !&@u&$nt$ '$n!*0$ [V*(+# nu' #&"+ u$#* ,$ +#'*t+\.
L*! $" *! !$ ($$n0.$-PR$ "+n $( *9+ p#&'$#+ !$@u&,+ p+# $( n/'$#+ ,$( '$! - &n*('$nt$ "+n $( nu'$#+ ,$ ,`*. P$0$'p(+ 2<< <411 $! (* $" * <4b11b2<< . E( !&!t$'* ,$5$ )*(&,*# u$ (* $nt#*,* ,$ (* $" * !$* "+##$"t*. SDBMun"&+n* "+n un* )$nt*n* ,$ $" *! "+n *9+! ,$!,$ 1 = 2< 4. L+! )*(+#$! p*#* (+! '$!$! !+n $nt$#+! p+!&t&)+!
m 1* . L+! ,`*! !+n $nt$#+! p+!&t&)+! ,+n,$n *+ $ "$pt+ p*#* $( '$! ,$ $5#$#+.No se preocupe por validar aIosbisiestosJ P$R: recuerde Gue hay meses de =KJ 'L o =& días4 D$ *5$# $##+# $n $( +#'*t+ ,$ $nt#*,* p*#* (* $" * ,$ &n,&"*#en donde $ &!t$ $( $##+# ,$ $nt#*,*.$%emplo de un mensa%e [En (* $" * <2b33b2<< $ &!t$ un $##+# $n $(,$( '$!\.
Fecha b'*-b2<< Nombre de la competencia S$ t*! C+'p$t$n"&*!Categoría E;PERTO Universidad UPR> B*-*'7nAutor Hu*n S+(_ S(+*n Tipo de Competencia P#+@#*'*"&7nProblema
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 60/499
:8:( FA/:R #$ N:-BRAR $! ARC;./: C:N $0T$ N:-BR$( SDBMS>IN.T;T
Sample Input (File: S ,-S IN./0/)$%emplo de entrada de un archivo(
V xml versi@n%X!&!1alp4aX encodin %X7'JD X WV;c4ema JormatWV6lp4anumericW1!VA6lp4anumericWVNumberW"&2VANumberWV=ateWyyyymmddVA=ateWV6lp4anumericW1VA6lp4anumericWVA;c4ema JormatWVAxmlW< VD Cantidad de recordsManc4e o,123$"&*<,1BB"!11*,El 4ombre de cemento,<*"$3&21,1B !123,BMordor,M1"&32,2!!"12!1,J
MC !$ <,!&"1,1B !2!<,6'rinity,*&*<,21!"!2!1,6;aruman,123.&! ,1B 33!1,andalf,2!!&!!,1BB211!3,'4e 4ite iHard
Sample Output (File: S ,-S O1/./0/)E( !&!t$'* ,$5$ &'p#&'&# un* (&!t* ,$5$ ($$# $( *#" &)+ ,$ $nt#*,* - (u$@+ @$n$#*# $( !&@u&$nt$output
5e istro 1: 9mportado sin errores&5e istro 2: 9mportado sin incluir 1! caracteres alfanumYricos parael campo 1&5e istro 3: Error: Car)cter no permitido en campo numYrico5e istro $: 9mportado sin errores5e istro ": Error: En la fec4a !2A!1A21!" existe un error en el a o5e istro *: Error: Car)cter no permitido en campo numYrico& En lafec4a 33A!1A1B existe un error en el valor del mes&5e istro <: 9mportado sin incluir 1" caracteres del valoralfanumYrico para el campo $&
:<
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 61/499
Universidad de Puerto RicoBayamónJ Puerto Rico
Euintas Competencias de Programación'KK+
23perto
:1
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 62/499
Fecha 24b*5#&(b2<<4Categoría E p$#t+Autor 3* COMPETENCIA IBEROAMERICANA DE
INFORM TICA
Problema 1
Nombre de la competencia u&nt*!C+'p$t$n"&*!Universidad UPR = B*-*'7nTipo de competencia P#+@#*'*"&7n
ENCA(AR.nput File Name( $NCA8AR4.N:utput File Name( MpantallaNarrativaEn un t*(($# $( +#,$n $! 'u- &'p+#t*nt$ -* u$ $! &n,&!p$n!*5($ t$n$# +#@*n&8*,*! t+,*! (*! $##*'&*"&(&t*# !u u5&"*"&7n. P$n!*n,+ $n $!t+ !$ * "+(@*,+ un t*5($#+ $n (* p*#$, !+5#$ $( "u*( !$ "+,$ (*! $##*'&$nt*!. Aun u$ $! un* 5u$n* !+(u"&7n6 !$ *"$ p#+5($'_t&"+ *@#$@*# nu$)*! $##*'&t*5($#+ "u*n,+ -* n+ u$,* 'u" + $!p*"&+ (&5#$.
En 5u!"* ,$ un* !+(u"&7n * $!t$ p#+5($'* !$ *n $!"*n$*,+ $n 5(*n"+ - n$@#+ $( t*5($#+ - (* $##*'&,$!$* "+(@*#. E( $!"*n$+ !$ "+'p+n$ ,$ un *##$@(+ ,$ 8+n*! "u*,#*,*! $n (*! "u*($! un* [;\ &n,&"* u"u5&$#t* p+# un* $##*'&$nt* - un punt+ .% un* 8+n* (&5#$. P+# $0$'p(+6 (* +#'* - $!"*n$+ ,$ un
###
###
&#&
&
#& &#&
L* nu$)* $##*'&$nt* !$#_ '*"&8*6 (+ u$ !&@n& &"* u$ t+,+! !u! punt+! !+n *,-*"$nt$! $nt#$ !` "+*( '$n+! un ) #t&"$%. A,$'_! $n !u $!"*n$+ !$ *n $(&'&n*,+ &(*! - "+(u'n*! )*"`*!.ProblemaS$ ,$!$* u$ u!t$, $(*5+#$ un p#+@#*'* u$ !+(u"&+n$ *ut+'_t&"*'$nt$ $!t$ p#+5($'* t$n&$n,+ "+'+ $(+! $!"*n$+! ,$( t*5($#+ ,$ $##*'&$nt*! - ,$ (* nu$)* $##*'&$nt* u$ !$ u&$#$ "+(@*#. D$5$ t+'*# u$ (* nu$)* $##*'&$nt* !7(+ pu$,$ !$# #+t*,* $n _n@u(+! '/(t&p(+! ,$ <o6 p+# (+ u$ !7(+ *5#_n "u+#'*! p+!&5($! ,$ u5&"*# (* $##*'&$nt* ,$nt#+ ,$( t*5($#+6 ,$!&@n*,*! "+n (+! "7,&@+! Q<..3
< PARA<
1 PARA<o
2 PARA1 <
PAR2 <
:2
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 63/499
L* nu$)* $##*'&$nt* ,$5$ +"up*# un* 8+n* ,$( t*5($#+ t*( u$ n+ ut&(&"$ 8+n*! -* +"up*,*! p+# +t#$##*'&$nt*! n+ p+,#`* "+(@*#!$%.
$ntrada ENCAHAR.IN
E!t$ *#" &)+ "+nt&$n$ &n +#'*"&7n u$ #$p#$!$nt* $( $!"*n$+ ,$( t*5($#+ - ,$ (* $##*'&$nt*.
!ínea &( t "t 1fX t6 "t fX2<<%. N/'$#+ ,$ &(*! - "+(u'n*! ,$( $!"*n$+ ,$( t*5($#+.
!ínea( 2.. t 1 Un* "*,$n* ,$ "t "*#*"t$#$! Q ;d6d.d #$p#$!$nt*n,+ un* (`n$* ,$( $!"*n$+.
!ínea( t 2 6 " 1fX 6 "fX1<<%. N/'$#+ ,$ &(*! - "+(u'n*! ,$( $!"*n$+ ,$ (* $##*'&$nt*.
!íneas( t 3.. t 2 Un* "*,$n* ,$ " "*#*"t$#$! Q ;d6d.d #$p#$!$nt*n,+ un* (`n$* ,$( $!"*n$+.
0alida( ENCAHAR.OUT
!ínea &( f, c. L*! "++#,$n*,*! ,$ (* p+!&"&7n ,$ (* $! u&n* !up$#&+# &8 u&$#,* ,$ (* $##*'&$nt* ,t*5($#+. E!t$ punt+ "+&n"&,$ "+n (* p+!&"&7n 16 1% ,$( $!"*n$+ ,$ (* $##*'&$nt*.
!ínea '( E( "7,&@+ ,$ (* +#'* $n u$ !$ "+(+"*#_ (* &@u#*6 ,$ *"u$#,+ * (+ ,$!"#&t+ *nt$#&+#>'$'_! ,$ un* !*(&,* )_(&,* p*#* un* $nt#*,*6 u!t$, ,$5$ #$p+#t*# !7(+ un* ,$ $((*!. S& n+ $! p+!&5($ unu$)* $##*'&$nt*6 $( *#" &)+ ,$ !*(&,* ,$5$ "+nt$n$# $( '$n!*0$ [N+ *- !+(u"&7n\.
!ínea = en adelante( E( ,&5u0+ ,$( t*5($#+ &n"(u-$n,+ (* $##*'&$nt* nu$)*. S$ ut&(&8*#_ $( *!t$#&&n,&"*# $n ,+n,$ $!t_ (* nu$)* $##*'&$nt*.
$%emplo,"&<
&(. ,,"&<
&(. &
"1!
3$
###U&&#&
3
#U###&#&
###U&&#&
###U&&#&
#UU&#&
#U###&#&
#U
&&#U
###..
U#&"3
#&&.....#&
### #&&..&#U
###&#&&#&&#&
:3
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 64/499
DIAGRAMA VISUAL DE LA NUEVA JERRAMIENTA EN EL TABLERO
1 2 3 $ " * < B !123
$"
:4
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 65/499
Fecha( 24<*5#&(<2<<4Catgoría( E p$#t+Autor( ACM Int$#n*t&+n*( C+(($@&*t$Problema 2
Nombre de la competencia( u&nt*!"+'p$t$n"&*!Universidad( UPR = B*-*'7nTipo de competencia( P#+@#*'*"&7n
Mor"e Mi"ma!c e"
.nput File Name( '+#!$.&n
S*'u$( F. B. M+#!$ &! 5$!t ?n+ n +# t $ "+,&n@ !" $'$ t *t "*##&$! &! n*'$. M+#!$ "+,$ &!u!$, &n &nt$#n*t&+n*( #*,&+ "+''un&"*t&+n. T $ "+,&n@ + t$ t u!&n@ M+#!$ "+,$ &! !tE*" " *#*"t$# "*!$ &! &n!&@n& &"*nt% &! t#*n!(*t$, t+ * p#$,$ &n$, !$ u$n"$ +dits *n, dahs t $$($'$nt! + M+#!$ "+,$%. D&t! *#$ #$p#$!$nt$, *! p$#&+,! [.\% *n, ,* ! *#$ #$p#$!$nt$, *! '&nu! !&@n! [>\%. E*" $($'$nt &! t#*n!'&tt$, 5- !$n,&n@ * !&@n*( +# !+'$ p$#&+, + t&#*t $# ! +#t6 *n, * ,* &!6 &n p$# $"t(- +#'$, "+,$6 t #$$ t&'$! *! (+n@ *! * ,&t. A ! +#t !&($*pp$*#! 5$t $$n $($'$nt!6 &t * (+n@$# !p*"$ 5$t $$n " *#*"t$#!. A !t&(( (+n@$# !p*"$ !$p+#,!. T &! ,$p$n,$n"$ &n t $ !p*"&n@ *n, t&'&n@ + $($'$nt! '$*n! t *t M+#!$ "+,$ +p$#*t+!+'$t&'$! ,+ n+t !$n, p$# $"t "+,$. T &! #$!u(t &n ,& &"u(t&$! +# t $ #$"$&)&n@ +p$#*t+##$ u$nt(- t $ '$!!*@$ "*n 5$ ,$"+,$, ,$p$n,&n@ +n "+nt$ t.
In t &! p#+5($' $ "+n!&,$# #$"$pt&+n + +#,! &n M+#!$ "+,$ &t +ut !p*"&n@ 5$t $$n ($tt$K&t +ut t $ !p*"&n@6 &t &! p+!!&5($ +# 'u(t&p($ +#,! t+ 5$ "+,$, t $ !*'$. F+# $ *'p($6 &'$!!*@$ [,&t ,&t ,&t\ $#$ #$"$&)$,6 &t "+u(, 5$ &nt$#p#$t$, *! [EEE6 EI6 IE\ +# [S\ 5*!$, +"+,&n@ !" $'$ ! + n &n t $ !*'p($ &nput. T+ ,$"&,$ 5$t $$n t $!$ 'u(t&p($ &nt$#p#$t*t&+n!6*!!u'$ * p*#t&"u(*# "+nt$ t 5- $ p$"t&n@ $*" #$"$&)$, +#, t+ *pp$*# &n * ,&"t&+n*#-.
F+# t &! p#+5($' -+u# p#+@#*' &(( #$*, * t*5($ @&)&n@ t $ $n"+,&n@ + ($tt$#! *n, ,&@"+,$6 * (&!t + $ p$"t$, +#,! conte&t %6 *n, * !$ u$n"$ + +#,! $n"+,$, &n M+#!$ "+,$ morse)T $!$ morse +#,! '*- 5$ (* $,. F+# $*" morse +#,6 -+u# p#+@#*' &! t+ ,$t$#'&n$ t $ '*t" &n+#, #+' conte&t 6 & *n-. I 'u(t&p($ +#,! #+'conte&t '*t" morse 6 +# & n+ +#, '*t" $!
p$# $"t(-6 -+u# p#+@#*' &(( ,&!p(*- t $ 5$!t '*t" &n@ +#, *n, * '&!'*t" &n,&"*t+#.
I * !&n@($ +#, #+'conte&t '*t" $! morse p$# $"t(-6 &t &(( 5$ ,&!p(*-$, +n * !&n@($ (&n$6 5I 'u(t&p($conte&t +#,! '*t" morse p$# $"t(-6 t $n !$($"t t $ '*t" &n@ +#, &t t $ $ $!t" *#*"t$#!. I t &! !t&(( #$!u(t! &n *n *'5&@u+u! '*t" 6 *n- + t $!$ '*t" $! '*- 5$ ,&!p(*-$,. I'u(t&p($conte&t +#,! $ &!t +# * @&)$nmorse 6 t $ '*t" &n@ +#, &(( 5$ ,&!p(*-$, +((+ $, *n$ "(*'*t&+n p+&nt [W\%.
K$ *!!u'$ +n(- * !&'p($ "*!$ + $##+#! &n t#*n!'&!!&+n &n &" $($'$nt! '*- 5$ $&t $# t#un"#+' t $ $n, + * morse +#, +# *,,$, t+ t $ $n, + * morse +#,. K $n n+ p$# $"t '*t" $! +#
morse *#$ +un,6 ,&!p(*- t $ +#, #+'conte&t t *t '*t" $! t $ (+n@$!t p#$ & +morse 6 +# *! t $$ $!t $ t#* $($'$nt! 5$-+n, t +!$ &n morse . I 'u(t&p($ +#,! &nconte&t '*t" u!&n@ t $!$ #u($!6*n- + t $!$ '*t" $! '*- 5$ ,&!p(*-$,. K+#,! t *t ,+ n+t '*t" p$# $"t(- *#$ ,&!p(*-$, &t *u$!t&+n '*#? [h\% !u & $,.
T $ &nput ,*t* &(( +n(- "+nt*&n "*!$! t *t *(( &t &n t $ p#$"$,&n@ #u($!.
:
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 66/499
.nput
T $ M+#!$ "+,$ t*5($ &(( *pp$*# &#!t *n, "+n!&!t! + (&n$! $*" "+nt*&n&n@ *n upp$#"*,&@&t C6 8$#+ +# '+#$ 5(*n?!6 *n, * !$ u$n"$ + n+ '+#$ t *n !& p$#&+,! *n, -p $n! @&)&M+#!$ "+,$ +# C. B(*n?! '*- p#$"$,$ +# +((+ t $ &t$'! +n t $ (&n$. A (&n$ "+nt*&n&n@ **!t$#&!? [e\%6 p+!!&5(- p#$"$,$, +# +((+ $, 5- 5(*n?!6 t$#'&n*t$! t $ M+#!$ "+,$ t*5($. Y+*!!u'$ t *t t $#$ &(( 5$ M+#!$ "+,$ @&)$n +# $)$#- " *#*"t$# t *t *pp$*#! &n t $conte&t !$"t&+n.
T $ conte&t !$"t&+n n$ t6 &t +n$ +#, p$# (&n$6 p+!!&5(- p#$"$,$, *n, +((+ $, 5- 5(*n?!. E*+#, &n "+nt$ t &(( "+nt*&n n+ '+#$ t *n t$n " *#*"t$#!. N+ " *#*"t$#! +t $# t *n upp$# "*!$*n, ,&@&t! &(( *pp$*#. T $#$, &(( 5$ *t '+!t 1<< "+nt$ t +#,!. A (&n$ "+nt*&n&n@ +n(- *!t$#&!? [e\%6 p+!!&5(- p#$"$,$, +# +((+ $, 5- 5(*n?!6 t$#'&n*t$! t $ "+nt$ t !$"t&+n.
T $ #$'*&n,$# + t $ &nput "+nt*&n!morse +#,! !$p*#*t$, 5- 5(*n?! +# $n,>+ >(&n$ " *#*"t$#!. A"+nt*&n&n@ +n(- * !&n@($ *!t$#&!? [e\%6 p+!!&5(- p#$"$,$, +# +((+ $, 5- 5(*n?!6 t$#'&n N+morse +#, &(( *)$ '+#$ t *n $&@ t- <% $($'$nt!.
:utputF+# $*" &nputmorse +#,6 ,&!p(*- t $ *pp#+p#&*t$ '*t" &n@ +#, #+'conte&t +((+ $, 5- *n$ "(*'*t&+n '*#? [W\% +# u$!t&+n '*#? [h\% & *pp#+p#&*t$. E*" +#, &! t+ *pp$*# +n *(&n$ !t*#t&n@ &n "+(u'n +n$.
0ample .nput =6 .- 6N> -> E65'L076 EC -.-. E6'= -.. K=E . L6'LJ ..-. 9M
--. 5E6=IL >. 'K9 .. L6'O .--- 5K'L
-.- ..-. & .-->..-- >..-->.
M DD --.----.. .--.-.----..N D& .-->..-- .--.K DDD ..-.-.->.--.-..-.--.-.P &DD& ..-- .->--..-.--0 DD&D ---- ..--
5 &D&
::
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 67/499
; U .' D :utput 7or the 0imple .nput7 ..- L6'Q &&D L6'L# D&&D K=I D&DD 5K'L
DD&& L6'! DDDDDD 6N
1 &DDDDD E65'L076 E2 &&DDD 9MZ3 UDD 5E6=I$ U&D 'K" U&D 9MZ* DU&< DDU
DDD&&B DDDD&
:
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 68/499
Fecha 24b*5#&(b2<<4 Nombre de la competencia u&nt*! C+'p$t$n"&*!Categoría E p$#t+ Universidad UPR> B*-*'7nAutor Hu*n M. S+(_ Tipo de Competencia P#+@#*'*"&7nProblema ( 3
$)*AT DE*RA+, E-E
.nput File Name(L>FAT. T;T:utput File Name( DEFRAG. T;T
L> FAT $! (* t*5(* ,$ (+"*(&8*"&7n ,$ *#" &)+! ut&(&8*,* p+# LECJON>DOS. U!t$, ,$5$ "+n!t#u&# un p#+@un L>FAT #*@'$nt*,+6 ,$5* p#+,u"&# un L>FAT ,$ #*@'$nt*,+.
$%emplo(L>FAT #*@'$nt*,+
0tartat .# Filename 0tart at $nd at
Ne5t.#
1 C<1 '+n!t#+.'p@ < << < A<21 M<4 < F&($1. ,(( 1< :4 1< 1 C2<13
< F <1 '+n!t#+.'p@
1 1 3 1 e
1 U< :1 ; &@.#p' 3 2 <<< e
< H<12 F&($1.,(( <1<<1 <2: e
< A<2 M+!t#+.' p@
1<<1 13 2 F <1
< C2<13 F&($1.,(( < : 1<<< H<12
L>FAT ,$ #*@'$nt*,+
0tartat .# File
Name0tart at $nd at
N$ tID
1 M<4 < F&($1.,(( < :<2 < e
1 C<1 '+!t#+.' p@
:<2 < :< 4: e
1 U< :1 ; &@.#p' :< 4: :<: 1: e
N+t$ (+ !&@u&$nt$1. L>FAT ,$ #*@'$nt*,+ !$ +#@*n&8* p+# +#,$n *( *5 t&"+ $n (* "+(u'n* ,$ [ &($n*'$\.
2. L+! *#" &)+! !$ "+(+"*n $'p$8*n,+ $n (* p+!&"&7n < $n $( ,&!"+ ,u#+.
3. E( "+'&$n8+ ,$ un *#" &)+ $!t_ '*#"*,+ "+n un 1 $n (* p#&'$#* "+(u'n*.
4. S$ p#$!$#)* $( ID ,$( p#&n"&p&+ ,$( *#" &)+ *( ,$ #*@'$nt*# $( L>FAT.
. Un < $n (* p#&'$#* "+(u'n* &,$nt& &"* * un #*@'$nt+ $n $( L>FAT #*@'$nt*,+.
:
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 69/499
:. L+! 5#&n"+! *"&* +t#+! #*@'$nt+! $n $( L>FAT #*@'$nt*,+ pu$,$n !$# *"&* un ID '_! *5*0+ + '_! *
(&!t*.
. A( ,$ #*@'$nt*# un *#" &)+ pu$,$ +"u##&# u$ +t#+ t$n@* u$ !$# '+)&,+ ,$( L>FAT p*#* *u$ $!t$ p#&
n+ ($ p*!$ p+# $n"&'* *( !$@un,+ *#" &)+.
$%emplo
f&nputZ!>FAT4TOT
0tartat .# Filename 0tart at $nd at
Ne5t.#
1 C<1 '+n!t#+.'p@ < << < A<21 M<4 < F&($1. ,(( 1< :4 1< 1 C2<13< F <1 '+n!t#+.'p@ 1 1 3 1 e1 U< :1 ; &@.#p' 3 2 <<< e< H<12 F&($1.,(( <1<<1 <2: e< A<2 M+!t#+.'p@ 1<<1 13 2 F <1< C2<13 F&($1.,(( < : 1<<< H<12
f+utputZ #$FRA94TOT
0tart
at.# File Name 0tart at $nd at
N$ t
ID1 M<4 < F&($1.,(( < :<2 < e1 C<1 '+!t#+.'p@ :<2 < :< 4: e1 U< :1 ; &@.#p' :< 4: :<: 1: e
:
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 70/499
Fecha 24b*5#&(b2<<4 Nombre de la competencia u&nt*! C+'p$t$n"&*!Categoría E p$#t+ Universidad UPR> B*-*'7nAutor Hu*n M. S+(_ Tipo de competencia P#+@#*'*"&7nProblema (4
Di.er"ión Con +rafo".nput File Name( G#* +.t t:utput File Name( M p*nt*((*Z
Un @#* + ,&#&@&,+ !$ #$p#$!$nt* "+n GX V6E% ,+n,$ V $! $( "+n0unt+ ,$ (+! n+,+! - E $! $( "+n0unt+ ,$ (*$0$'p(+ ,$ !u *#" &)+ ,$ $nt#*,* $!
fNu'$#+ ,$ N+,+!Z* 5",$4 fNu'$#+ ,$ *#t&!t*!Z*65 56*,6* 56"
9 2/J$6VXm*656"6,6$ - EXm *65%6 ,6*%6 56"%
D$5$ "(*!& &"*# (+! n+,+! ,$ (* !&@u&$nt$ +#'*
N+,+ * $! u$#t$'$nt$ "+n$ + "+n 5 N+,+ 5 $! u$#t$'$nt$ "+n$ + "+n * N+,+ 5 $! "+n$ + "+n " N+,+ , $! "+n$ + "+n * N+,+ $ $! ,&!"+n$ +
N+t*
1. N+ $ &!t$n "&"(+! $n (+! @#* +! ,*,+! ,$ $nt#*,*. S+(+ pu$,$ "(*!& &"*# $n t#$! "(*!$! Fuertemente cone&o, cone&o o discone&o2. Un n+,+ * $! u$#t$'$nt$ "+n$ + "+n 56 !& $ &!t$ un *#&!t* ,$( n+,+ * *( n+,+ 5 - ,$( n+,+ 5 *( n+,+ * E
*65% - 56*%%.3. Un n+,+ $! "+n$ + !& $ &!t$ un* *#&!t* ,$ !*(&,* * +t#+ n+,+ E0$'p(+ ,6*%%4. Un n+,+ $! ,&!"+n$ + !& n+ $ &!t$ un* *#&!t* ,$ !*(&,* n& ,$ $nt#*,* *"&* $(. E0$'p(+ n+,+ $%.. Un n+,+ u$ $! u$#t$'$nt$ "+n$ +6 t*'5& n $! un n+,+ "+n$ +. P+# $n,$ NO ,$5$ (&!t*# *( n+,+ * "+'+ "+
"+n 5 -* u$ $! u$#t$'$nt$ "+n$ + "+n $( n+,+ 5.
:re%ita( UtiliQar matriQ de adyacencia
<
* 5
$
",
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 71/499
Universidad de Puerto RicoBayamónJ Puerto Rico
Euintas Competencias de Programación'KK+
Intermedio
1
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 72/499
Fecha 24b*5#&(b2<<4 Nombre de la competencia u&nt*! C+'p$t$n"&*!Categoría Int$#'$,&+ Universidad UPR> B*-*'7nAutor 4t+C+'p$t$n"&* I5$#+*'$#&"*n* ,$ In +#'_t&"* Tipo de competencia P#+@#*'*"&7nProblema 1
PARENT.nput File Name( PAR$NT4.N:utput File Name( PAR$NT4 :UT
#escripción
S$ t&$n$ un* !$"u$n"&* ,$ t*'*9+ p*# ,$ p*# nt$!&! $n ,+! $!t*,+! p+!&5($! *5&$#t+! - "$##*,+! %d - !$ ,$!$*(@un+! ,$ +#'* t*( u$ !$ +5t$n@* un* !$"u$n"&* )_(&,* ,$ p*# nt$!&! *5&$#t+! - "$##*,+!.
T*#$*D*,* un* !$"u$n"&* ,$ t*'*9+ p*# ,$ *!t* 1.<<< p*# nt$!&!6 $n"+nt#*# $( n/'$#+ ,$ p*# nt$!&! u$ ,$5$n "*'5&*$!t*,+ p*#* u$ !$* un* !$"u$n"&* )_(&,*.
E0$'p(+
S$* (* !$"u$n"&* %%
L* !$"u$n"&* n+ $! )_(&,*6 p*#* *"$#(* )_(&,* !$ pu$,$n *"$# $n ,+! p*!+!6 un* ,$ !u! !+(u"&+n$! $! (* !&@u"*'5&*n,+ (*! p+!&"&+n$! 163 - : !$ +5t&$n$ % % %6 !&$n,+ $!t* un* !$"u$n"&* ,$ p*# nt$!&! )_(&,*.
Ent#*,* PAR$NT4.N
En (* p#&'$#* - /n&"* (`n$* ,$( *#" &)+ *p*#$"$ un* "*,$n* ,$ (+n@&tu, p*# L O fXL fX 1.<<<% +#'*,* p+# - %d !&n $!p*"&+! $nt#$ $((+!.
S*(&,*PAR$NT4:UT
En (* p#&'$#* (`n$* ,$( *#" &)+ ,$ !*(&,* ,$5$ *p*#$"$# $( )*(+# ,$ M6 &n,&"*n,+ $( '`n&'+ ,$ p*# nt$!&! u$ !"*'5&*# p*#* +5t$n$# un* !$"u$n"&* )_(&,* - $n (* !$@un,* (`n$* M $nt$#+! !$p*#*,+! p+# $!p*"&+ &n,&"*,,+n,$ !$ ,$5$n *"$# (+! "*'5&+!. S& n+ $! n$"$!*#&+ *"$# "*'5&+!6 $( *#" &)+ ,$ !*(&,* !7(+ "+nt$n,#_ un* (n/'$#+ <.
$8$-P!:
PAR$NT4 .N PAR$NT4 :UT%% 3
14:
2
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 73/499
Fecha(24b*5#&(b2<<4 Nombre de la competencia u&nt*!C+'p$n"&*!
Categoría Int$#'$,&+ Universidad UPR> B*-*'7nAutor 1 2 ACM S" +(*!t&" P#+@#*''&n@ C+nt$!tTipo de Competencia P#+@#*'*"&7nProblema 2
Spread" ee! Calcula!or
.nput File Name(SPRCAL.IN:utput File Name( SPRCAL. OUT
A !p#$*,! $$t &! * #$"t*n@u(*# *##*- + "$((!. C$((! "+nt*&n ,*t* +# $ p#$!!&+n! t *t "*n 5$ $)*(u*t$ t+ +5t*&[!&'p($\ !p#$*,! $$t &! +n$ &n &" ,*t* *#$ &nt$@$#! *n, $ p#$!!&+n! *#$ '& $, !u'! *n, ,& $#$n"$! + &nt$#! #$ $#$n"$!. F+# *n- $ p#$!!&+n6 & $*" "$(( t *t &! #$ $#$n"$, "+nt*&n! *n &nt$@$#6 t $n t $ $ p#$!!&+n "*nt $ &nt$@$# t+ &" t $ $ p#$!!&+n $)*(u*t$!. Y+u *#$ t+ #&t$ * p#+@#*' &" $)*(u*t$! !&'p($ !p#$*,! $$t!.
.nput
Input "+n!&!t! + * !$ u$n"$ + !&'p($ !p#$*,! $$t!. E*" !p#$*,! $$t 5$@&n! &t * (&n$ !p$"& -&n@ t $ nu'5$#*n, t $ nu'5$# + "+(u'n!. N+ !p#$*,! $$t "+nt*&n! '+#$ t *n 2< #+ ! +# 1< "+(u'n!. R+ ! *#$ (*5$($, 5- "*p&t*(($tt$#! A t #+u@ T. C+(u'n! *#$ (*5$($, 5- ,$"&'*( ,&@&t! < t #+u@ . T $#$ +#$6 t $ "$(( &n t $ &#!t #+ *n,"+(u'n &! #$ $#$n"$, *! A<a t $ "$(( &n t $ t $nt&$t #+ *n, & t "+(u'n! &! #$ $#$n"$, *! T4.
F+((+ &n@ t $ !p$"& &"*t&+n + t $ nu'5$# + #+ ! *n, "+(u'n! &! +n$ (&n$ + ,*t* +# $*" "$((6 p#$!$nt$, &n #+#,$#. %T *t &!6 *(( "$((! +# t $ &#!t #+ "+'$ &#!t6 +((+ $, 5- *(( "$((! +# t $ !$"+n, #+ 6 $t".% E*" "$(( &n"+nt*&n! * !&@n$, &nt$@$# )*(u$ +# *n $ p#$!!&+n &n)+()&n@ un!&@n$, &nt$@$# "+n!t*nt!6 "$(( #$ $#$n*,,&t&+n% *n, = !u5t#*"t&+n%. IF * "$(( &n&t&*((- "+nt*&n! * !&@n$, &nt$@$#6 t $ "+##$!p+n,&n@ &np+pt&"*( '&nu! !&@n +((+ $, 5- +n$ +# '+#$ ,$"&'*( ,&@&t!. I * "$(( &n&t&*((- "+nt*&n! *n $ p#$!!&+n6 &t"+nt*&n +n$ +# '+#$ "$(( #$ $#$n"$! +# un!&@n$, &nt$@$# "+n!t*nt! !$p*#*t$, #+' $*" +t $# 5- *n, = !&@n'u!t 5$@&n &t * "$(( #$ $#$n"$. N+ $ p#$!!&+n "+nt*&n! '+#$ t *n " *#*"t$#!. N+ (&n$ + &nput "+nt*&n! 5(*n?!. N+ $ p#$!!&+n "+nt*&n! *n- $'5$,,$, 5(*n?!. J+ $)$#6 *n- (&n$ '*- "+nt*&n t#*&(&n@ 5(*n?!.
T $ $n, + t $ !$ u$n"$ + !p#$*,! $$t &! '*#?$, 5- * (&n$ !p$"& -&n@ < #+ ! *n, < "+(u'!.
:utput
F+# $*" !p#$*,! $$t &n t $ &nput6 -+u *#$ t+ ,$t$#'&n$ t $ )*(u$ + $*" $ p#$!!&+n *n, ,&!p(*- t $ #$!u(t&n@ *! * #$"t*n@u(*# *##*- + nu'5$# &t t $ #+ ! *n, "+(u'n! *pp#+p#&*t$(- (*5$($,. In $*" ,&!p(*-6 *(( nu'5$#! +"+(u'n 'u!t *pp$*# t&@ t>0u!t& &$, *n, *(&@n$, &t t $ "+(u'n (*5$(. Op$#*t+#! *#$ $)*(u*t$, ($ t t+ #&@ t &$ p#$!!&+na )*(u$! &n "$((! *#$ *( *-! ($!! t *n 1<<<< &n *5!+(ut$ )*(u$. S&n"$ $ p#$!!&+n! '*- #$ $#$n"$ "$(t $'!$()$! "+nt*&n $ p#$!!&+n!6 t $ +#,$# &n &" "$((! *#$ $)*(u*t$, &! ,$p$n,$nt +n t $ $ p#$!!&+n! t $'!$()$!.
I +n$ '+#$ "$((! &n * !p#$*,! $$t "+nt*&n $ p#$!!&+n! &t "&#"u(*# #$ $#$n"$!6 t $n t $ +utput +# t *t !p#$*,!"+nt*&n +n(- * (&!t + t $ un$)*(u*t$, "$((! &n #+ >'*0+# +#,$#6 +n$ p$# (&n$6 &t $*" (&n$ "+nt*&n&n@ t $
"+(+n6 * 5(*n?6 *n, t $ "$((d! +#&@&n*( $ p#$!!&+n.
3
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 74/499
A 5(*n? (&n$ ! +u(, *pp$*# +((+ &n@ t $ +utput +# $*" !p#$*,! $$t. S*'p($ &nput *n, +utput *#$ 5$(+ .
S*'p($ Input Output +# t $ S*'p($ Input2 2 ! 16lF>1 6 3 "" > 3 D23>KD6l 6K: 6K2 2 >K: Cl6K Cl:"Cl<6lF>l>KF6l
! !
4
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 75/499
F$" * 24b*5#&(b2<<4 N+'5#$ ,$ (* "+'p$t$n"&* u&nt*! C+'p$t$n"&*C*t$@+#`* Int$#'$,&+ Un&)$#!&,*, UPR> B*-*'7nAut+# N$((&u, D. T+##$! T&p+ ,$ "+'p$t$n"&* P#+@#*'*"&7nP#+5($'* 3
ESCA$ERA ARITM/TICA
L+! *nt&@u+! G#&$@+! ,$!"u5#&$#+n "+'+ "+n!t#u&# $( (*#@+ ,$ (+! n/'$#+! &##*"&+n*($! ut&(&8*n,+ $(E((+! ut&(&8*5*n p+(`@+n+! - "+n"$pt+! ,$ (`'&t$! p*#* "*("u(*# $( _#$* ,$ un "`#"u(+. T*'5& n ,$!*##+((*#+$!"*($#* *#&t' t&"* ut&(&8*n,+ #*,&+! p*#* *p#+ &'*# $( )*(+# ,$ (+! n/'$#+! &##*"&+n*($!. T#*5*0* ,$ (* !+#'*n ,+! "+(u'n*! - (*! ,+! )*n * "+'$n8*# "+n $( n/'$#+ un+ 1%. S& (+ (($)*'+! * "&n"+ p*!+!6 (* $!"*($#* !$#`!&@u&$nt$
PA0:0 !A##$R &
!A##$R '
< 1 11 2 3
23 12 14 2 41
<
D$!*##+(($ un p#+@#*'* u$ ($ p&,* *( u!u*#&+ ,+! n/'$#+! &n&"&*($! - (* "*nt&,*, ,$ p*!+! u$ ,$!$* )$# ,$ u'_ &'+ ,$ )$&nt$ 2<%%.
$%emplo Corrida(
Ent#$ (+! ,+! n/'$#+! &n&"&*($! 1 = %=
Ent#$ (* "*nt&,*, ,$ p*!+! u$ ,$!$* "+t$0*# 1 >2<%'' N/'$#+ &n"+##$"t+6 t#*t$ ,$ nu$)+Ent#$ (* "*nt&,*, ,$ p*!+! u$ ,$!$* "+t$0*# 1 = 2<%,
A p*#t&# ,$( p*!+ un+6 (+! n/'$#+! ,$ (* "+(u'n* ((*'*,*[LADDER 1\ !$ +#'*n ut&(&8*n,+ $( !&@u&$nt$ p#+"$,&'&$nt+
P*!+ 1 1 1 X 2P*!+ 2 2 3 X P*!+ 3 X 12P*!+ 4 12 1 X 2
P*!+ 2 41 X <L+! n/'$#+! ,$ (* "+(u'n* ((*'*,* [LADDER 2\ !$ +#'*nut&(&8*n,+ $( !&@u&$nt$ p#+"$,&'&$nt+
P*!+ 1 1 2 X 3P*!+ 2 2 X P*!+ 3 12 X 1P*!+ 4 12 2 X 41P*!+ 2 < X
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 76/499
PASOS LADDER 1 LADDER 2
< 3 1 112 1 23 4: :4 111 1
2: 3: :4 1
:
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 77/499
Fecha 24b*5#&(b2<<4 Nombre de la competencia u&nt*! C+'p$t$n"&*!Categoría( Int$#'$,&+ Universidad UPR = B*-*'7nAutor( N$((&u, D. T+##$! Tipo de competencia P#+@#*'*"&7nProblema ( 4
N0M#ER PROPERTIES
A p+!&t&)$ &nt$@$# &! "+n!&,$#$, p#&'$ & &t &! $)$n(- ,&)&!&5($ +n(- 5- &t!$( *n, 1. A(!+6 5- "+n)$nt& p#&'$. T u!6 t $ !$ u$n"$ + p#&'$! 5$@&n!2636 6 61161361 6
A p+!&t&)$ &nt$@$# &! "*(($, p$# $"t & &t &! t $ !u' + &t! p#+p$# ,&)&!+#!. F+# $ *'p($6 2 &! * p$# $"t nu1 2 4 14.
Y+u# *!!&@n'$nt &! t+ #&t$ * p#+@#*' t *t &(( &nput * !$ u$n"$ + &nt$@$#!6 +n$ p$# (&n$6 *n, +utput t $&nt$@$# &n t $ +((+ &n@ +#'*t
I t $ nu'5$# &! n$&t $# p#&'$ n+# p$# $"t6 +utput [Du((\.I t $ nu'5$# &! p#&'$ 5ut n+t p$# $"t6 +utput [P#&'$\.I t $ nu'5$# &! p$# $"t 5ut n+t p#&'$6 +utput [P$# $"t\.I t $ nu'5$# &! 5+t p#&'$ *n, p$# $"t6 +utput [T &! p#+@#*' ,+$!ndt +#?\.
A(( &nput! &(( 5$ p+!&t&)$ &nt$@$#!. T $ $n, + &nput &(( 5$ '*#?$t 5- t $ nu'5$# < n+ +utput ! +u(, 5$ @$n
$5ample(
9nput
2<1$!1
"!
Kutput
PerfectPrime=ull=ull
Prime
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 78/499
Universidad de Puerto RicoBayamónJ Puerto Rico
Cuartas Competencias de Programación'KK=
23perto
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 79/499
Fecha 2:b*5#&(b2<<3 Nombre de la competencia 4t*! C+'p$t$n"&*! Int$#un&)$#!&t*#Categoría E p$#t+ Universidad UPR>B*-*'7nAutor Fu#'*n Un&)$#!&t- 2<<< Tipo de competencia P#+@#*'*"&7nProblema 1
A Real Pu11ler
Input F&($ N*'$ prob&4inOutput to the screen
#escription(A " &(,#$nd! pu88($ t *t *! p+pu(*# &n t $ ,*-! 5$ +#$ )&,$+ @*'$! "+n!&!t$, + * 5- #*'$ &" "+nt*&!'*(( t&($! + $ u*( !&8$. A un& u$ ($tt$# + t $ *(p *5$t *! p#&nt$, +n $*" !'*(( t&($. S&n"$ t $#$ $#t&($! &t &n t $ #*'$6 t $ #*'$ *(!+ "+nt*&n$, *n $'pt- p+!&t&+n &" *! t $ !*'$ !&8$ *! * !'*(( t&($. "+u(, 5$ '+)$, &nt+ t *t $'pt- p+!&t&+n & &t $#$ &''$,&*t$(- t+ t $ #&@ t6 t+ t $ ($ t6 *5+)$ +# 5$(+
p+!&t&+n. T $ +50$"t + t $ pu88($ *! t+ !(&,$ t&($! &nt+ t $ $'pt- p+!&t&+n !+ t *t t $ #*'$ ,&!p(*-$&n *(p *5$t&"*( +#,$#. T $ &((u!t#*t&+n 5$(+ #$p#$!$nt! * pu88($ &n &t! +#&@&n*( "+n &"+n &@u#*t&+n * t$# t $ +((+ &n@ !$ u$n"$ + : '+)$!
1. T $ t&($ *5+)$ t $ $'pt- p+!&t&+n &! '+)$,.2. T $ t&($ t+ t $ #&@ t + t $ $'pt- p+!&t&+n &! '+)$,.3. T $ t&($ t+ t $ #&@ t + t $ $'pt- p+!&t&+n &! '+)$,.4. T $ t&($ 5$(+ t $ $'pt- p+!&t&+n &! '+)$,.. T $ t&($ 5$(+ t $ $'pt- p+!&t&+n &! '+)$,.:. T $ t&($ t+ t $ ($ t + t $ $'pt- p+!&t&+n &! '+)$,.
T R 9 0 8
O # : D .
- / ! N
@ P A B $
U E ; C F
T R 9 0 8
O : D ! .
- # / B N
@ P A $
U E ; C F
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 80/499
Input +# -+u# p#+@#*' "+n!&!t! + !$)$#*( pu88($!. E*" &! ,$!"#&5$, 5- &t! &n&t&*( "+n &@u#*t&+n *n'+)$! +n t $ pu88($. T $ &#!t (&n$! + $*" pu88($ ,$!"#&pt&+n *#$ t $ !t*#t&n@ "+n &@u#*t&+n. T $ n$t $ !$ u$n"$ + '+)$!.
T $ &#!t (&n$ + t $ &nput "+##$!p+n,! t+ t $ t+p (&n$ + t&($! &n t $ pu88($. T $ +t $# (&n$! +((+ &n $'pt- p+!&t&+n &! &n,&"*t$, 5- * 5(*n?. E*" &nput (&n$ "+nt*&n! $ *"t(- " *#*"t$#!6 5$@&nn&n@ &t tt $ ($ t'+!t t&($ +# * 5(*n? & t $ ($ t'+!t t&($ &! t $ $'pt- #*'$ p+!&t&+n%.
T $ !$ u$n"$ + '+)$! &! #$p#$!$nt$, 5- * +n$ (&n$ !$ u$n"$ + A!6 B!6 R! *n, L! t+ ,$n+t$ &" t&($ '+)$! &t $ $'pt- p+!&t&+n. A ,$n+t$! t *t t $ t&($ *5+)$ t $ $'pt- p+!&t&+n '+)$!a B ,$n+t$! t *t t $ t&($ 5$(+ t $ $'pt p+!&t&+n '+)$!a L ,$n+t$! t *t t $ t&($ t+ t $ ($ t + t $ $'pt- p+!&t&+n '+)$!a R ,$n+t$! t *t t $ t&($ t+ t $ #&@t $ $'pt- p+!&t&+n '+)$!.
Input &(( 5$ t$#'&n*t$, &t 1 8$#+ <% &n t $ pu88($ ,$!"#&pt&+n.
Output +# $*" pu88($ 5$@&n! &t * pu88($ (*5$( Pu88($ 16 Pu88($ 26 $t".%. T $ &n*( "+n &@u#*t&+n! +u(, t $n 5$ p#&nt$,. F+#'*t $*" (&n$ +# * &n*( "+n &@u#*t&+n !+ t *t t $#$ &! * 5(*n? " *#*"t$# 5$*,0*"$nt ($tt$#!. T#$*t t $ $'pt- t&($ t $ !*'$ *! * ($tt$#. S$p*#*t$ +utput #+' ,& $#$nt pu88($ #$"+#,! 5- +n$ (&n$.
$5ample(
Input (? < @ ' M : , +&
$ 7" &(( & "
?7'< M,
+ ( $: @(&&&0
Output +uAAle B1# ( ? < @ '
M : , + &
$ 7 "
+uAAle B2# & " ? 7 ' M , < + ( $ : @
Additional notes(Y+u '*- *!!u'$ t *t t $ &nput &(( "+##$!p+n, t+ * ($@&t&'*t$ pu88($. In *,,&t&+n6 *(( !$ u$n"$! + '+)$! &(( 5$ )*(&&(( n+t '+)$ +ut!&,$ t $ 5+un,! + t $ pu88($. N+ !$ u$n"$ &(( 5$ (+n@$# t *n < " *#*"t$#!.
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 81/499
Fecha 2:b*5#&(b2<<3 Nombre de la competencia 4t*! C+'p$t$n"&*! Int$#un&)$#!&t*#&*!Categoría E p$#t+ Universidad UPR>B*-*'7nAutor ACSL-1998 Tipo de competencia P#+@#*'*"&7nProblema 2
+o
T $ @*'$ + G+ &! p(*-$, +n *n >5-> 5+*#,. T $#$ *#$ t + p(*-$#!6 &t$ K% *n, 5(*"? B%. T $ p(*-$#! t*?$ tu#n! p(*"&n@ * p&$"$ + t $&# "+(+# +n t $ 5+*#,6 &t t $ @+*( + "*ptu#&n@ t $ p&$"$. Y+u "*ptu#$ -+u# +pp+n$nt ! p&$"$ 5- !u##+un,&n@ &t &t -+u# + n p&$"$! +n t $ +#&)$#t&"*( !&,$!.
T $ 5+*#,! 5$(+ &((u!t#*t$ t $ "*ptu#$ + * !&n@($ &t$ p&$"$6 $n t $ &t$ p&$"$ &! &n t $ &$,@$6 *n, "+#n$# #+' ($ t>t+>#&@ t%. N+t$ t *t +n(- t + + -+u# p&$"$! *#$ n$$,$, t+ "*ptu#$ *n+pp+n$nt ! p&$"$ *t * "+#n$#6 *n, t #$$ p&$"$! *#$ n$$,$, $n t $ +pp+n$nt &! +n * ! u*#$ *(+n@$,@$.
T+ '*?$ t &! p#+@#*' '+#$ " *(($n@&n@ * t$# *((6 t &! &! t $ A((>St*# C+nt$!t%6 -+u n$$, t+ "@(+5! + p&$"$!. T *t &!6 @#+up! + p&$"$! + +n$ "+(+#6 *(( t+u" &n@ $*" +t $# +#&8+nt*()$#t&"*((-6 t *t *#$ "+'p($t$(- !u##+un,$, +#&8+nt*((- *n, )$#t&"*((- 5- p&$"$! + t $ +t $# "+(+#
5+*#, *t t $ ($ t &((u!t#*t$! 3 &t$ @(+5!a &n t $ '&,,($ 5+*#,6 t $ @(+5 *t t $ (+ $#>($ t *! 5$$n"*ptu#$, u!&n@ t $ $ $!t nu'5$# + 5(*"? p&$"$!a *n, &n t $ #&@ t 5+*#,6 *(( t #$$ @(+5! *)$ 5$"*ptu#$,6 *@*&n u!&n@ t $ $ $!t nu'5$# + 5(*"? p&$"$! p+!!&5($
T $ &nput t+ t &! p#+@#*' &(( 5$ !$t! + ,*t*. E*" !$t &(( "+n!&!t + * 5+*#, "+n &@u#*t&+n. -+u t $ +#'*t (*t$#.% Y+u n$$, t+ #$p+#t t $ 5$!t '+)$ +# $*" p(*-$#. B- 5$!t '+)$6 $ '$*n t $ p(*"$ +n t $ 5+*#, t *t +u(, "*ptu#$ t $ '+!t +pp+n$nt ! p&$"$!. I t $#$ *#$ n+ !u" (+"*t&+n!6 p#&n+n$. I t $#$ &! '+#$ t *n +n$ (+"*t&+n6 -+u 'u!t p#&nt *((. T $ 5$!t '+)$ +# &t$ +# $*""+n &@u#*t&+n &! +#t 1 p+&nt $*" a t $ 5$!t '+)$ +# 5(*"? +# $*" 5+*#, "+n &@u#*t&+n &! p+&nt $*" .
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 82/499
T+ '*?$ t-p&n@ t $ ,*t* $*!- +n t $ p#+"t+#!6 $ (( $n"+,$ t $ :4 (+"*t&+n! +n t $ 5+*#, &n 5&n*#-$*" p(*-$#. T *t &!6 * :4>5&t !t#&n@ &(( @&)$ *(( p+!&t&+n! $#$ 5(*"? p&$"$! #$!&,$6 *n, 5&t !t#&n@ &(( @&)$ t $ &t$ p&$"$!. AND&n@ t $ t + !t#&n@! t+@$t $# &! @u*#*nt$$, t+ #!t#&n@ t *t &! *(( 8$#+ !. T &n? *5+ut &t.% T $ 5+*#, &! $n"+,$, #+' ($ t>t+>#&@ t6 5+tt+'>t+>t+p. T *t &!6t $ (+ $# ($ t "+#n$# &! t $ ($*,&n@ 5&t + t $ :4>5&t !t#&n@6 t $ "$(( *5+)$ &t t $ t '+!t !&@n&*n, !+ +n.
T $ 5&t>!t#&n@! &(( 5$ "+n)$#t$, t+ 5*!$ 1:. T $ #&@ t'+!t 5+*#, &n t $ !$"+n, !$t + &'*@$! *5$n"+,$, *! B<2 4A1 F C :B1< +# 5(*"? *n, *!4<D< B<E2 <: 3 1<<< +# &t$.
A! '$nt&+n$,6 +# $*" 5+*#, "+n &@u#*t&+n6 p#&nt t $ 5$!t '+)$ $*" p(*-$# "+u(, '*?$ & $ $#$n$ t. E*" !$t + &nput #$!u(t! &n t + +utput!6 $*" +#t +n$ p+&nt. P#&nt t $ (+"*t&+n + t $ 5$!t *! * nu'5$# #+' 1 t +u@ :46 '*pp&n@ t+ t $ p+!&t&+n + t *t "$(( &n t $ 5&t !t#&n@. F+# &n!t*n&t$ p&$"$ &n t $ ($ t'+!t 5+*#, &n t $ t+p !$t + &'*@$! &! *t "$(( 44. I n+ '+)$ +u(, #$!u(t &n t
"*ptu#$ + *n- + t $ +pp+n$nt ! p(*-$#!6 p#&nt t $ !t#&n@ n+ &n.
0ample .nput(
ine 1: !!!$ 1 !1 !"3! "2!B !!!1 $$1! $2C 2B !
ine 2: 12!$ !!! 12!! 21!$ !1 ! 22 ! !! $ 1! !
0ample :utput(
Kutput 1: blac : $ and "B Kutput 2: w4ite: *3 Kutput 3: blac : 1* Kutput $: w4ite: no win
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 83/499
Programming Problem #2 – o ! E" er$o
Te%$ Da$a In &$'
?1: !!C 11!! $2$! 1 1!$ ! $! 2"2! $2!2 ?2: $!2! !C3! $6$! 3!B! 31$2 2!! 3!3! !"!1
?3: JJ!! E<!! BB1 E<!! !!E< 1 BB !!E< !!JJ ?$: !2! !$!2 !!B! 211! !!!2 3 $! !1* !!!! ?": 1! 2!!2 B$2 1!> !362 !! "2 $!1
Te%$ Da$a O&$ &$'
?1: blac : 2 ?2: w4ite: "* ?3: blac : $" ?$: w4ite: 1 ?": blac : 12 and 13 ?*: w4ite: "2 and "3 ?<: blac : no win ? : w4ite: no win ?B: blac : "!?1!: w4ite: 2, 2", 3 , and "Note: There are 5 inputs; each input results in two outputs, one for black and one for white. Thelabels "black" and "white" are optional. Outputs 5, 6, and 10 ha e !ore than one alue; all !ustbe present to recei e credit, and the !a appear in an order. Outputs # and $ !ust be the strin%"no win."
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 84/499
Fecha 2:b*5#&(b2<<3 Nombre de la competencia 4t*! C+'p$t$n"&*! Int$#un&)$#!&t*#&*!Categoría E p$#t+ Universidad UPR>B*-*'7nAutor ACSL-1998 Tipo de competencia P#+@#*'*"&7nProblema 3
2D Tic)Tac)Toe
This problem takes the game of tic-tac-toe to a higher dimension. Consider threetic-tac-toe boards aligned above each other such that there are ! cubes in "hichto place a marker. The game is pla#ed bet"een t"o pla#ers$ % and &$ b# takingturns placing a marker in one of the cubes. The "inner is the first pla#er to getthree in a ro". &f course$ the cubes do not need to be from the same board'ho"ever$ connecting the centers of the cubes does need to form a straight line.
There "ill be 1( sets of data. )ach set consists of an initial configuration of %*s and&*s$ follo"ed b# the placement of the ne+t ,%,.
The initial configuration is given b# a string that is ! characters long consisting of%*s$ &*s$ and *s for blanks/. The string K.K..#.#KK.#.#.KK.#.#.#...K represents thefollo"ing three boards0
The placement of the ne+t ,%, is given b# an integer$ 1 through !$ representingthe ! cubes in the board. The numbering scheme is the same order as the !-character long string representing the initial configuration. or e+ample$ the &*s onthe boards above are at positions 1$ 2$ 9$ 1($ 13$ 1!$ and !.
or each input set$ determine if ,%, "ins$ and if so$ "hich t"o other cubes on theboards contribute to the "in. 4f ,%, "ins in more than one "a#$ #ou must print all"a#s. 4f ,%, cannot "in$ print a message to that effect.
Sam le In &$'
ine 1: K.K..#.#KK.#.#.KK.#.#.#...K, " ine 2: #K..#.K..K...#.##K..#...K.K, 11
Sam le O&$ &$'
Kutput 1: 1$ and 23 Kutput 2: 1$ and 1<T 1 and 21
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 85/499
5rogramming 5roblem 62 - (D Ti)!Ta)!Toe !E" er$o
Te%$ Da$a In &$'
?1: .#K..#K.KKK..#.K.#..K.#.#.#, 22 ?2: .#.K#.#KK.K##....K.K.#..K.#, 3 ?3: #.#.#.K.KK.K.K.#.##.#...K.K, 23
?$: #K..#.K#.K.K#KK#.#.K..#KK##, 1< ?": .KK#K.##.K#.KK.#K#KK#.#..#., 2" ?*: KK.K.###K.KK#KK#.#.#.##.K.., 1B ?<: K#..KKK.#.##KK......##....., 1" ? : ...K#.#KK#.K#.#KK#.K#.#...K, 1$ ?B: K..##.KK#.K...K..#K##.##.KK, 1$?1!: .K..K#K#KK#K##K#.##K#K.#K#K, 23
Te%$ Da$a O&$ &$'
?1: * and 1$ ?2: " and < ?3: NK 9N
?$: 1* and 1 T and 2* ?": < and 1*T 21 and 23 ?*: < and 13 ?<: B and 21 ? : " and 23T < and 21T 1! and 1 T 13 and 1" ?B: " and 23T $ and 2$?1!: NK 9N
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 86/499
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 87/499
Sam le In &$'
ine 1: 2, ", $", $, D3! ine 2: $, 2, B!, 2, 1 !, 2, 2<!, 2, !
Sam le O&$ &$'
Kutput 1: *&BBB, 1&"3" Kutput 2: !, !
Programming Problem #* ! Trea%&re I%lan+ ! E" er$o
Te%$ Da$a In &$'
?1: 3, 2, $", 2, 3!, 2, *! ?2: 3, 2, D$", 2, D3!, 2, D*!
?3: 3, 2, B!, 2, 1 !, 2, 2<! ?$: 3, 2, DB!, 2, D1 !, 2, D2<! ?": 3, 2, 3!, 2,3!, 2, 3! ?*: $, 2, D$", 2, DB!, 2, D1 !, 2, 1 ! ?<: $, 2, 3*!, 2, D3*!, 2, <2!, 2, D<2! ? : $, 2, D$", 2, D13", 2, D22", 2, D31" ?B: $, 2, 3B!, 2, <"!, 2, D12!, 2, D1 !?1!: ", 2, !, 2, B!, 2, DB!, 2, D2<!, 2, D1 !
Te%$ Da$a O&$ &$'
?1: $&1$*2*, $&1$*2* ?2: $&1$*2*, D$&1$*2* ?3: D2, ! ?$: D2, ! ?": "&1B*1", 3 ?*: D2&" "< , D3&$1$21 ?<: , ! ? : !,! ?B: &$*$1!1, &2*<B$B?1!: !, 2
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 88/499
Universidad de Puerto RicoBayamónJ Puerto Rico
Cuartas Competencias de Programación'KK=
Intermedio
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 89/499
Fecha 2:b*5#&(b2<<3 Nombre de la competencia 4t*! C+'p$t$n"&*! Int$#un&)$#!&t*#&Categoría Int$#'$,&+ Universidad UPR>B*-*'7nAutor P#+ . N$((&u, D. T+##$! Tipo de competencia P#+@#*'*"&7nProblema 1
ESTRE$$ASArchivos(
Input $!t#$((*!.,*tOutput NbA
#e7inición(Un observatorio astronómico requiere de un programa que analice una fotografía del cielo tomada porla noche. La información de la fotografía está almacenada en forma de tabla, donde cada elementorepresenta la cantidad de luz que se registró para cada punto. Los valores registrados van del 0 al 20,por e emplo!
0 " # 0 0 0 $ %& '" $ 0 0 0 2 "2 $ 2 ( " 0 '0 00 0 # '& # ' % 00 0 ( '2 $ ) '0 #& 0 $ '0 $ # % 0
La persona encargada de analizar la información supone que ha* una estrella en + i4 j si!
• el punto no se encuentra en las orillas de la fotografía +primero o -ltimo renglón o columna ,*
• (a5i4 j6 7 a5i '4 j6 7 a5i 7 '4 j6 7 a5i4 j '6 7 a5i4 j 7 '6) 8 9
e espera como resultado del análisis, una tabla b con un / 1 en las pare as + i4 j en las que sesupone que ha* una estrella. l resto de la tabla debe quedar lleno de espacios. La tabla bque resulta del e emplo anterior es!
' 2 " # & $ ( %'2"
#&$
Problema(
3ealice un programa en 455 que!1. Lea las dimensiones de la tabla m * n con +' m4 n .2. Lea los valores de cada elemento de la tabla a .3. 4onstru*a la tabla b.
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 90/499
4. 6mprima la tabla b.
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 91/499
$%emplo de .nput(
NbA = L$$# (* t*5(* ,$ un *#" &)+
$%emplo de :utput 20creen6(
' 2 " # & $ ( %'2"#&$
E( t+t*( ,$ $!t#$((*! $!
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 92/499
Fecha 2:b*5#&(b2<<3 Nombre de la competencia 4t*! C+'p$t$n"&*! Int$#un&)$#!&t*#&*!Categoría Int$#'$,&+ Universidad UPR>B*-*'7nAutor Fu#'*n Un&)$#!&t- 2<<< Tipo de competencia P#+@#*'*"&7nProblema 2
Super *re3Input File Name: prob2.inOutput: to the screen
Description:
A character is known to its homeboys as a super freq if it occurs with frequency strictly greater than 15% ina gi en passage of te!t" #rite a program that rea$s an A &II te!t file an$ i$entifies all the 'nglishalphabet (A)*+ a),- super freqs in that te!t file" .our program shoul$ be case insensiti e"
/here will only be one passage of te!t in the input file+ an$ it will consist of a single line"
0se all characters in the file (inclu$ing spaces an$ punctuation- in calculating the frequency of aparticular alphabet character+ but you $on t ha e to compute the frequency of these 2e!tra3 characters"
Example:Input: Sally sells sea shells by the sea shore.Output: S is a super freq.
Input: How now brown cow.Output: O is a super freq.
W is a super freq.
Input: Hey Sam!
Output: here are no super freqs.
""itional notes:
/he input file will not contain any tabs+ carriage returns or other special formatting characters"
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 93/499
Fecha 2:b*5#&(b2<<3 Nombre de la competencia 4t*! C+'p$t$n"&*! Int$#un&)$#!&t*#&*!Categoría Int$#'$,&+ Universidad UPR>B*-*'7nAutor ACSL-1998 Tipo de competencia P#+@#*'*"&7nProblema 3
Po"!4In
=iven an e+pression in a functional language e+pressed in postfi+$ convert it toinfi+. The language "ill consist of the unar# function abs and the binar# functions!in and !a& . >ead each input as a single string' the output should have a spaceafter each comma.
Sam le Da$a sets of data' the test data has 1( sets of data/0
In &$ O&$ &$2 D$ min abs 2 1 max max max-abs-min-2, D$//, max-2, 1//
2 21 13 max min abs abs-min-2, max-21, 13///
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 94/499
Program # (, Po%$2In - In$erme+io
In &$ O&$ &$1 2 max max-1, 2/
1 2 3 max min min-1, max-2, 3//
1 2 max 3 min min-max-1, 2/, 3/
11 22 max 33 $$ min max max-max-11, 22/, min-33, $$//
! abs abs abs-abs-!//
1 D2 min abs abs-min-1, D2//
1 abs D2 min min-abs-1/, D2/
1 abs 2 abs min min-abs-1/, abs-2//
D1 abs D2 abs min abs abs-min-abs-D1/, abs-D2///
11 D2 max D33 $$ D" max min min min-max-11, D2/, min-D33, max-$$, D"///
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 95/499
Fecha 2:b*5#&(b2<<3 Nombre de la competencia 4t*! C+'p$t$n"&*! Int$#un&)$#!&t*#&*!Categoría Int$#'$,&+ Universidad UPR>B*-*'7nAutor ACSL-1998 Tipo de competencia P#+@#*'*"&7nProblema 4
#o!c agaloop
The botcha%aloop value of a number & is found as follo"s. irst$ convert & to base8. Call this p . ?e+t$ sort the digits of p in increasing order. Call this ' . Subtract 'from p in base 8$ of course/. >epeat the ,sort-subtract, se;uence more times$or until the digits in the result are in sorted order "hichever come first/. inall#$convert the number back to base 1(.
or e+ample$ 2 18 has a botchagaloop value of 1((8. 4t is computed as follo"s0
2 18 < 3 2 base 8/'
1. 3 2 - 2 3 < 1 '. 1 - 1 < (!'
2. (! - ! < 2('. 2( - 2 < (( '. (( - < 1!3('
and finall#$ 1!3( < 1((8 base 1(/.
?ote that there is at least one subtraction and at most subtractions.
There "ill be inputs. )ach is a positive integer less than 1$((($(((. 5rint thebotchagaloop value of each input.
Sam le In &$'
Enter number: 3$1
Sam le O&$ &$'
'4e number is: 1!!
Sam le In &$'
Enter number: 123
Sam le O&$ &$'
'4e number is: 2
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 96/499
Universidad de Puerto RicoBayamónJ Puerto Rico
Cuartas Competencias de Programación'KK=
;rincipiante
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 97/499
Fecha 2:b*5#&(b2<<3 Nombre de la competencia 4t*! C+'p$t$n"&*! Int$#un&)$#!&t*#&*!Categoría P#&n"&p&*nt$ Universidad UPR>B*-*'7nAutor P#+ . N$((&u, D. T+##$! Tipo de competencia P#+@#*'*"&7nProblema 1
CON(ET0RA DE 0$$MANArchivos(
Input NbAOutput NbA
#e7inición(
La con etura de Ullman establece que si empiezas con cualquier n-mero positivo, alaplicar el siguiente procedimiento, siempre te va a dar uno!
'. mpezar con cualquier entero positivo.2. i es par, dividirlo entre dos.". i es impar se multiplica por tres +" * se le suma uno+' .#. 7or cada entero que se obtenga que no sea uno +' se vuelve a repetir los pasos 2 *
"&. 8l final, se debe obtener uno +' .
Problema(
9esarrolle un programa que le solicite al usuario un n-mero entero * comienze amostrar en pantalla los resultados de los pasos 2 * " hasta que llegue a uno.
$%emplo de corrida(
Ent#$ un n/'$#+ $nt$#+ p+!&t&)+',
2: L+ ,&)&,+ $nt#$ ,+!13 Mu(t&p(&"+ p+# 3 - ($ !u'+ 14< L+ ,&)&,+ $nt#$ ,+!2< L+ ,&)&,+ $nt#$ ,+!1< L+ ,&)&,+ $nt#$ ,+!
Mu(t&p(&"+ p+# 3 - ($ !u'+ 11: L+ ,&)&,+ $nt#$ ,+! L+ ,&)&,+ $nt#$ ,+!4 L+ ,&)&,+ $nt#$ ,+!2 L+ ,&)&,+ $nt#$ ,+!1 R$!u(t*,+ F&n*(
I'p+#t*nt$ T&$n$ u$ p+n$# (* "+##&,* $ *"t*'$nt$ "+'+ !$ )$ * u`.
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 98/499
Fecha 2:b*5#&(b2<<3 Nombre de la competencia 4t*! C+'p$t$n"&*! Int$#un&)$#!&t*#&*!Categoría P#&n"&p&*nt$ Universidad UPR>B*-*'7nAutor P#+ . N$((&u, D. T+##$! Tipo de competencia P#+@#*'*"&7nProblema 2
5ISTO+RAMA DE PA$A#RAS
Archivos(
Input p*(*5#*!.t tOutput NbA
#e7inición(S$ u&$#$ p+,$# *"$# un &!t+@#*'* )$#t&"*( u$ &n,& u$ (* "*nt&,*, ,$ "*#*"t$#$! u$ t&
p*(*5#* ut&(&8*n,+ *!t$#&!"+!.
Problema(
D$!*##+(($ un p#+@#*'* u$ ($* p*(*5#*! ,$ un* *#" &)+ ((*'*,+ [p*(*5#*!.t t\ - 'u$!t#$ $n p*nt*((* un &!t+@#*'* +#&8+nt*( ,$ "*,* p*(*5#*. En $( *#" &)+ "*,* p*(*5#* $!t*#_ !$p*#*,* $!p*"&+ $n 5(*n"+.
$%emplo de .nput(
Un *#" &)+ u$ t$n@* (+ !&@u&$nt$$sta es una muestra de archivo
$%emplo de :utput20creen6(
P6 6>56 L9;'K 56M6
Esta ....es ..una ...muestra .......de ..arc4ivo .......
.mportante6 n&n@un* p*(*5#* !$#_ '*-+# ,$ 1 "*#*"t$#$!. C*,* p*(*5#* pu$,$ t$n$# ($t#*! '*-/!"u(*! + '&n/!"u(*!. T&$n$ u$ &n"(u&# $($n"*5$8*'&$nt+ "+'+ !$ 'u$!t#* * u` - (* &n,$nt*"&7n $nt#$ (* p*(*5#* - (*!t$#&!"+!.
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 99/499
Fecha 2:b*5#&(b2<<3 Nombre de la competencia 4t*! C+'p$t$n"&*! Int$#un&)$#!&t*#&*!Categoría P#&n"&p&*nt$ Universidad UPR>B*-*'7nAutor ACSL-1998 Tipo de competencia P#+@#*'*"&7nProblema 3
Cabracci
The terms of the ibonacci se;uence are the numbers 1$ 1$ $ 2$ $ 8$ 12$ .... Thene+t term in the se;uence is found b# summing the previous t"o terms.
?umbers in a (abracci se;uence are formed b# summing the previous three termsand subtracting 2. or e+ample$ the Cabracci se;uence starting "ith 1$ ($ and isas follo"s0 1$ ($ $ $ 2$ 3$ 8$ 1 $ $ ....
There "ill be sets of data. )ach set consists of four integers0 a1$ a $ a2$ and ?.The first three numbers are the first three terms of a Cabracci se;uence. Thefourth number is the term to print. or each input set$ print the ?th term of theCabracci se;uence defined b# the first three numbers in the input set.
Sam le In &$' Screen/
Enter $ numbers: 1 ! $ B
Sam le O&$ &$' Screen/
'4e number is: 2"
Sam le In &$' Screen/
Enter $ numbers: 1 1 2 "
Sam le In &$' Screen/
'4e number is: 1
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 100/499
Programming Problem = S Cabracci > Principiantes
Te%$ Da$a In &$'
?1: 1, 1, 1, 1!?2: 1, 3, ", 12?3: D1, D2, D3, 1!
?$: 2, $, *, ?": ", 1!, 1", *
Te%$ Da$a O&$ &$'
?1: D"1?2: *<!?3: D3 *?$: B1?":
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 101/499
Fecha 2:b*5#&(b2<<3 Nombre de la competencia 4t*! C+'p$t$n"&*! Int$#un&)$#!&t*#&*!Categoría P#&n"&p&*nt$! Universidad UPR>B*-*'7nAutor Fu#'*n Un&)$#!&t- 1 Tipo de competencia P#+@#*'*"&7nProblema 4
#alanced Paren! e"e"
Input PARENTESIS.T;TOutput NbA SCREEN%
Description:
#rite a program that checks an arithmetic e!pression for balance$ parentheses" Fore!ample+ e!pressions containing the sequences ( - an$( ( ( - ( - - - are balance$ but (--( an$ (((-- are not"
/he input file contains a series of e!pressions+ one per line4 each line is en$e$ with acarriage return" For each e!pression" $eci$e only if it has balance$ parentheses" 'chothe e!pression an$ in$icate whether it #' )FO67'8 or NO/ #' )FO67'8"
Example:
Input:#2$%&&##'($2&)#*'%&&
*+,&%)2&
Output:#2$%& -S WE '/O01ED#2&& -S O WE '/O01ED##'($2&)#*'%&& -S WE '/O01ED*+, -S WE '/O01ED&%)2& -S O WE '/O01ED
""itional notes:
/he program $oes not ha e to account for the rest of the e!pression+ that is+ whether theoperators an$ operan$s are legal or not" It is require$ to test only for parentheses"
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 102/499
Universidad de Puerto RicoBayamónJ Puerto Rico
Terceras Competencias de Programación'KK'
;rincipiante
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 103/499
Fecha 2<b*5#&(b2<<2 Nombre de la competenciallllllll Categoría P#&n"&p&*nt$ Universidad UPR> B*-*'7nAutor llllllllll Tipo de Competencia lllllllllll Problema ( Algoritmos lllllllllllllllllll
Common $e!!er"
Problema(
K#&t$ * p#+@#*' t *t t*?$! t + +#,! *n, &n,! *n- "+''+n ($tt$#! t *t t $- *)$. F+# $ *'p($6 t $+#,! "+'put$#d *n, p#+@#*'d *)$ t $ ($tt$#! +d6 'd6 pd6 #d6 &n "+''+n. T $ +utput ! +u(, 5$
5+t +#,! &t *(( "+''+n ($tt$#! &n "*p&t*(!. N$&t $# +#, &(( *)$ '+#$ t *n ($tt$#!.
$%emplo de .nput(
Enter two words : computer pro ram
$%emplo de :utput(
cKMPute5 P5K 5aM
T$!t -+u# p#+@#*' &t t $ +((+ &n@ p*&#! + +#,!
4ello allbye all
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 104/499
Fecha 2<b*5#&(b2<<2 Nombre de la competenciallllllllll Categoría P#&n"&p&*nt$! Universidad UPR> B*-*'7nAutor llllllllllllll Tipo de competenciallllllll Problema ( Algoritmos lllllllllllll
S!ring Compre""ion
Problema(
C+n!&,$# t $ !t#&n@ AAAABCCCCCDDDDd "+n!&!t&n@ + *(p *5$t&" " *#*"t$#! +n(-. T &!($n@t 14. S&n"$ t $ !t#&n@ "+n!&!t + *(p *5$t&" " *#*"t$#! +n(-6 ,up(&"*t$ " *#*"t$#! "*n 5$*n, #$p(*"$, &t * ,up(&"*t&+n *"t+# n. K&t t &! t$" n& u$ t $ !t#&n@ "*n 5$ "+'p#$!!$, *n,#$p#$!$nt&n@ 5- 4AB C4Dd. T $ "+'p#$!!$, !t#&n@ &! + ($n@t . K#&t$ * p#+@#*' &" t*?$&n "+'p#$!!$, +#' *n, #$"#$*t$! t $ +#&@&n*( un"+'p#$!!$, !t#&n@.
$%emplo d .nput(
T $ !t#&n@ &(( 5$ + t $ +#'*t nA d $#$ n6 t $ ,up(&"*t&+n *"t+#6 &! *n &nt$@$# 5$t $$n 2 **n, A &! *n upp$#"*!$ *(p *5$t&" " *#*"t$#. A !t#&n@ '*- "+nt*&n !&n@($ " *#*"t$#! n+t p#$ &,up(&"*t&+n *"t+#. I t &! $#$ n+t t $ "*!$6 +# &n!t*n"$6 t $ !t#&n@ AABCDEd +u(, 5$ "+'p#AABCDEd +u(, 5$ "+'p#$!!$, t+ 2ABCDEd.T $ '* &'u' ($n@t + *n &nput !t#&n@ &! < " *#*"t$#!.
$%emplo de :utput(
T $ un"+'p#$!!$, !t#&n@6 4< " *#*"t$#! p$# (&n$ &t '*- 5$ n$"$!!*#- t+ 5#$*? *n un"+'p#$!!$, !t+)$# 'u(t&p($ (&n$!%.
$5ample &
.nputEntre el strin : 3&4 !
:utput666>>>>=======$5ample '
.nputEntre el strin : 22 !&"18 ?
:utput======================6666666CJJJJJJJJJJJJJJJJJJ =
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 105/499
Fecha 2<b*5#&(b2<<2 Nombre de la competencialllllllll Categoría P#&n"&p&*nt$ Universidad UPR>B*-*'7nAutor P#+ . N$((&u, D. T+##$! Tipo de Competencialllllllllll Problema ( Algoritmos llllllllllllllll
DECIMA$ COMP$EMENTS
#e7inición(
Mu" *! "+'put*,+#*! p*#* #$p#$!$nt*# un n/'$#+ n$@*t&)+6 (+ *('*"$n*n "+'+ !u "+'p($'$nt+ *#&t' t&"+. E!t+ p$#'&tu$ *( $ $"tu*# un* #$!t*6 !$ pu$,* ut&(&8*# (* !u'* - +5t$n$# $( #$!u(t*,+ $!p$#*,+. P*#* +5t$n$# $( "+'p($'$nt+ ,$ un/'$#+ $n nu$!t#+ !&!t$'* nu' #&"+ ,$"&'*(6 t$n$'+! p#&'$#+ u$ "*("u(*# $( "+'p($'$nt+ 5*!$ nu$)$ ,$( n/'$#+. E!t+ $!6"u*nt+! n/'$#+! *(t*n p*#* u$ $( ,`@&t+ !$ "+n)&$#t* $n nu$)$. P+# $0$'p(+ $( "+'p($'$nt+ 5*!$ nu$)$ ,$ $! 46 ,$ 3 ,$ 3 $! ,$ < $! - *!` p+# $( $!t&(+. E( "+'p($'$nt+ 5*!$ ,&$8 !$ +5t&$n$ *( !u'*#($ un+ *( "+'p($'$nt+ 5*!$ nu$)$. E( p#+"$,&'&$nt+ u$ $0$"ut* un* "+'put*,+#* p*#* #$!t*# '$,&*nt$ (* !u'* $! $( !&@u&$nt$
1. Sup+n@*'+! u$ t$n$'+! (* !&@u&$nt$ #$!t* :142>4 1:2. C+n)$#t&'+! $( !u!t#*$n,+ 4 1: $n "+'p($'$nt+ 5*!$ nu$)$ (+ "u*( ,* 1 3.3. L$ !u'*'+! un+ *( #$!u(t*,+ 1 3 1X 1 44. Su'*'+! *'5+! n/'$#+! :142 1 4X1132:. E(&'&n*'+! $( /(t&'+ ,`@&t+ * (* &8 u&$#,* - +5t$n$'+! $( #$!u(t*,+ 132:
Problema(
D$!*##+(($ un p#+@#*'* u$ !+(&"&t$ *( u!u*#&+ un* #$!t*. Lu$@+ 'u$!t#$ $n p*nt*((* t+,+! (+! p*!+! n$"$!*#&+!+5t$n$# $( #$!u(t*,+ ut&(&8*n,+ $( "+'p($'$nt+ 5*!$ 1<.
$%emplo de .nput(
Ent#$ un* #$!t*=' > & =
$%emplo de :utput(
N/'$#+ !$($""&+n*,+ 1 3C+'p($'$nt+ 5*!$ nu$)$ 4:C+'p($'$nt+ 5*!$ ,&$8 4R$!u(t*,+ ,$ (* !u'* 11 4R$!u(t*,+ 1 4
N+t*[ % Espacio en >lanco
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 106/499
Fecha <4b2<b2<<2 Nombre de la competencialllllllllll Categoría P#&n"&p&*nt$ Universidad UPR>B*-*'7nAutor Ant+n&+ Ju$#t*! Tipo de Competenciallllllll Problema ( Algoritmos lllllllllllll
#ANNER N0MERICO
Problema(
D$!*##+(($ un p#+@#*'* u$ "+n)&$#t* un ,*t+ nu' #&"+ $nt#*,+ p+# p*nt*((* $n un [B*nn$#\. S7(+ !$ *"$pt*#_n n/'(+! !`'5+(+! - >. E( t*'*9+ ,$( ,`@&t+ ,$5$ !$# ,$ : "+(u'n*! p+# &(*!. A "+nt&nu*"&7n un $0$'p(+ ,$ "*,* ,`@&t+.
!! 11 !! 222222 333333 4 !! 4 !! 555555 6666661111 !! !!!!! 2 !!!!! 3 4 !! 4 !! 5 !!!!! 6 !!!!!1 ! 11 !! 222222 333333 4 $$ 4 $$ 555555 666666!! 11 !! 2 !!!!! !!!!! 3 !!! 4 !! !!!!! 5 6 !!!! 6111111 222222 333333 !!! 4 !! 555555 666666
0!!!!! 888888 999999 000000 !!FF!! !!!!!! !!!!! ! 8 !!!! 8 9 !!!! 9 0 0 !FF!! !!!!!! !!!!! ! 888888 999999 0 CC FFFF DDDDDD !!!!! ! 8 !!!! 8 !!!!! 9 0 0 !FF!! !!!!!! !!!!! ! 888888 999999 000000 !!FF!! !!!!!!
E( !`'5+(+ < #$p#$!$nt* un $!p*"&+ $n 5(*n"+.
$%emplo de .nput(
Ent#$ un n/'$#+ 3
$%emplo de :utput(
++ ====== LLLLLL ++ = L L ++++++ ====== LLLLLL ++ = L L ++ ====== LLLLLL
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 107/499
Universidad de Puerto RicoBayamónJ Puerto Rico
Terceras Competencias de Programación'KK'
Intermedio
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 108/499
F$" * 2<b*5#&(b2<<2 N+'5#$ ,$ (* C+'p$t$n"&* lllllll C*t$@+#`* Int$#'$,&+ Un&)$#!&,*, UPR> B*-*'7nAut+# lllllllll T&p+ ,$ C+'p$t$n"&* lllllllllllll P#+5($'* A(@+#&t'+! llllllllllllll
6E$$ ORDERED N0M#ERS
#e7inición(
T $ nu'5$# 13 &! "*(($, $((>+#,$#$, 5$"*u!$ t $ ,&@&t! &n t $ nu'5$# 1636 % &n"#$*!$ #+' ($ t t+ #&@ t 1 f3 f %. nu'5$# 3: &! n+t $((>+#,$#$, 5$"*u!$ : &! (*#@$# t *n .
Problema(
K#&t$ * p#+@#*' t *t &(( &n, *n, ,&!p(*- *(( p+!!&5($ t #$$ ,&@&t $((>+#,$#$, nu'5$#!. R$p+#t t $ t+t*( nu'5$# + ,&@&t $((>+#,$#$, nu'5$#!.
$%emplo de :utput(
$5ample
T $ t #$$ ,&@&t $(( +#,$#$, nu'5$#! *#$123 124 12 12: 12 12 12 13413 13: 13 13 13 14 14: 1414 14 1 : 1 1 1 1: 1:4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 44 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4: : :
T $ t+t*( nu'5$# &! hh
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 109/499
Fecha 2<b*5#&(b2<<2 Nombre de la Competencia llllllllllll Categoría Int$#'$,&+ Universidad UPR> B*-*'7nAutor llllllllll Tipo de Competencia lllllllllllll Problema ( Algoritmos llllllllllllllll
5ORI7ONTA$ 5ISTO+RAM
Problema(
K#&t$ * p#+@#*' t *t *""$pt! * !$t + ,&@&t! < t+ % *! &nput *n, p#&nt! * +#&8+nt*( &!t+@#*' #$p#$!$nt&n@ t$*" ,&@&t.
T$!t -+u# p#+@#*' &t t $ !$t + 13 ,&@&t!16 1626 66 61636 6 6 6 6<
$%emplo de .nput(
Enter a Number: 12Enter 12 di its:1,<,2,B,*,<,1,3,<,",<,B
$%emplo de :utput(
<1 e e2 e3 e4
e: e
e e e e
e e
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 110/499
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 111/499
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 112/499
Universidad de Puerto RicoBayamónJ Puerto Rico
Terceras Competencias de Programación'KK'
23perto
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 113/499
Fecha 2<b*5#&(b2<<2 Nombre de la Competencia lllllllllll Categoría E p$#t+ Universidad UPR>B*-*'7nAutor lllllllll Tipo de Competencia lllllllllllll Problema ( Algoritmos lllllllllllll
898 C5EC ER C5A$$EN+ER
Problema(
E *'&n$ t $ : : " $"?$#5+*#, 5$(+ *n, n+t$ t *t t $ !& " $"?$#! *#$ *##*n@$, +n t $ 5+*#, !+ t *t + n *n, +n(-+n$ &! p(*"$, &n $*" #+ *n, $*" "+(u'n6 *n, t $#$ &! n$)$# '+#$ t *n +n$ &n *n- ,&*@+n*(. D&*@+n*(! #un #+' !+t+ n+#t $!t *n, !+ut $!t t+ n+#t $*!t *n, &n"(u,$ *(( ,&*@+n*(!6 n+t 0u!t t $ '*0+# t +.%
C+(u'n1 2 3 4 :
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>1 >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>2 >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>3 >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>4 >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>: >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
T $ !+(ut&+n ! + n *5+)$ &! ,$!"#&5$, 5- t $ !$ u$n"$ 2 4 : 1 3 6 &" @&)$! t $ "+(u'n p+!&t&+n! + t $ " $"?$#! +# $#+ #+' 1 t+ :.
5K 1 2 3 $ " *
CK 7MN 2 $ * 1 3 "
T &! &! +n$ !+(ut&+n t+ t $ : : C $"?$#! C *(($n@$. K#&t$ *! p#+@#*' t *t !$*#" $! *n, &n,! *(( un& u$ !+(ut&+n! !$t+ t $ : : C $"?$#! C *(($n@$. P#&nt +ut t $ !+(ut&+n u!&n@ t $ "+(u'n n+t*t&+n ,$!"#&5$, *5+)$ *n, "+unt t $ t+t*( n+ !+(ut&+n! +un, &n"(u,&n@ #$ ($"t&+n *n, #+t*t&+n!%.
$%emplo de :utput(
2 $ * 1 3 "3 * 2 " 1 $
'LE5E 65E ;K 7'9KN; 'K 'LE *#* CLEC E5; CL6 EN E.
<
<
<
<
<
<
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 114/499
F$" * 2<b*5#&(.2<<2 N+'5#$ ,$ (* "+'p$t$n"&* llllll C*t$@+#`* E p$#t+ Un&)$#!&,*, UPR>B*-*'7nAut+# N$((&u, D. T+##$! T&p+ ,$ "+'p$t$n"&* llllllllll P#+5($'* A(@+#&t'+! llllllllllllllllll
N;MERO OC0$TOArchivos(
Input OCULTO.INPOutput NbA
#e7inición(
D$ *"u$#,+ * un* t*5(* ,*,* ,$ )*(+#$!6 ,$t$#'&n$ "u*( $! $( n/'$#+ +"u(t+. C*,* $! u$'* ,$ p&!t*! "+n (*! u$ u!t$, p+,#,$,u"&# un n/'$#+ "+'pu$!t+ p+# "u*t#+ "& #*! ,&!t&nt*! $($@&,*! ,$( < *( %6 u$ n+ $'p&$8* "+n "$#+. En (* "+(u 5&$n% &n,&"*'+! "u_nt+! ,`@&t+! *- *((` $n "+'/n "+n $( n/'$#+ 5u!"*,+ - $n (* '&!'* p+!&"&7n. En (* "+(u'n* R ,$#$@u(*#% !$ &n,&"* (* "*nt&,*, ,$ ,`@&t+! $n "+'/n p$#+ $n p+!&"&7n &n"+##$"t*. S& $n *(@/n "*!+ $n"u$nt#* t,`@&t+! u$ +#'*n $( n/'$#+ '&!t$#&+!+ - n+ ,* "+n $( #$!t*nt$ u$ n+ $! n&n@un+ ,$ (+! ,`@&t+! u$ &nt$#)&$n$n $n/'$#+!>p&!t*% ,$5$#_ 5u!"*# "u_( $! $( ,`@&t+ u$ n+ +#'* p*#t$ ,$ ,&" +! n/'$#+!>p&!t*. S& !$ t#*t* ,$ un /n&"+ n*u!$nt$6 !$ !$#_ $( "u*#t+ ,`@&t+ 5u!"*n,+.
EHEMPLOS
E( n/'$#+ +"u(t+ $! :1 <
B R
1<2<
12<1:
11<1
11<
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 115/499
Problema(
D$!*##+(($ un p#+@#*'* u$ ($* un* t*5(* ,$ un *#" &)+ ,$ Input - 'u$!t#$ "+'+ Output $( n/'$#+ !$"#$t+.
$%emplo de .nput(
4 2 < 1
3 < 2 4 1 2 1 2
3 4 2 <$%emplo de :utput(
EL NÚMERO OCULTO ES 1 32$%emplo de otras tablas con sus respuestas(
N+t*• X E!p*"&+ $n B(*n"+
B R
11231
<1<3:
2<4
212<4
EL NUMERO OCULTO ES 43 2
B R
<1<42
<<34
<1<14
11<4
EL NUMERO OCULTO ES 21
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 116/499
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 117/499
Fecha( 2<<*5#&(<2<<2 Nombre de la competencia( llllllllllllllllllllll Categoría( E p$#t+ Universidad( UPR>B*-*'7nAutor( P#+ . N$((&u, D. T+##$! Tipo de competencia( llllllllllllllllllllllllll Problema ( Algoritmos( llllllllllllllllllllllllllllllllll
M0$TIP$ICACI<N POR E$ M/TODO DE $A RE(I$$A
Archivos(
Input NbAOutput NbA
#e7inición(En (* In@(*t$##* ,$( !&@(+ ;VI6 (+! $!tu,&*nt$! ,$ '*t$'_t&"*! u!*5*n un !&!t$'* ,$ 'u(t&p(&"*"&7n u$6 *un
pu$,* p*#$"$# un p+"+ &n"7'+,+6 ,* (* #$!pu$!t* "+##$"t* #_p&,*'$nt$. S$ ((*'* $( ' t+,+ ,$ (* #$0&((* - +p$#* ,$ (*!&@u&$nt$ +#'*.
Sup+n@*'+! u$ !$ ,$!$* 'u(t&p(&"*#&'= p+#+ ,
&4 D&5u0*'+! un* '*t#&8 ,$ 3 3 - $!"#&5&'+! un+ ,$ (+! n/'$#+! $n (* p*#t$ ,$ *##&5* - $( +t#+ $n (* p*#t$ ,$ *5*0+T*'5& n ,&)&,&'+! ,&*@+n*('$nt$ "*,* un* ,$ (*! "$(,*!.
1 2 3
4
:
'4 S$ 'u(t&p(&"* $( n/'$#+ &n*( ,$ "& #* !up$#&+# 3% p+# "*,* un+ ,$ (+! n/'$#+! ,$ (* "& #* u$ $!t_ * (* ,$#$" *. #$!u(t*,+ !$ *('*"$n* $n (* "$(,* $n ,+n,$ &nt$#!$"*n. S& $( #$!u(t*,+ ,$ (* 'u(t&p(&"*"&7n $! '*-+# ,$ nu$)$6 !$ $( !$@un,+ ,`@&t+ $n (* p*#t$ !up$#&+# ,&*@+n*(. Su -* *5`* un n/'$#+ $n $!* p+!&"&7n6 !$ pu$,$n !u'*#. E!$ #$p&t$ "+n (+! +t#+! ,+! ,`@&t+! 1 -2%.
1 2 3
<4
< 12 4
< 1<
1
<:
12
1:
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 118/499
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 119/499
Fecha(<4<2<<2<<2 Nombre de la competencia( lllllllllllllllllllllll Categoría( E p$#t+ Universidad( UPR>B*-*'7nAutor( P#+ . Hu*n M. S+(_ Tipo de competencia( lllllllllllllllllllllllllll Problema ( Algoritmos( llllllllllllllllllllllllllllllllllll
5TM$ CODE OPTIMI7ER
A(@un+! $,&t+#$! ,$ p_@&n*! ,$ Int$#n$t "+(+"*n t*@! ,$ JTML #$,un,*nt$!. In"(u!&)$ $ &!t$n t*@! "+n "+nt$n&,E0$'p(+ fPZ fbPZ. E!t$ $! un t*@ u$ *5#$ - "&$##* un p_##* + "+n un $!p*"&+ *,$nt#+. Ot#+ p+!&5($ p#+5($'* $!$n"+nt#$'+! un p_##* + u$ *5#$ - "&$##* - u$ !7(+ t&$n$ $!p*"&+!6 t*5! - $nt$#. D$nt#+ ,$ JTML $ &!t$n t*@! #$,P+# $0$'p(+ $n un* t*5(* t$n$'+! t*@! ,$ (* !&@u&$nt$ '*n$#* fTABLEZ fTDZ1. "+nt$n&,+fbTDZfTRZfTDZ2.C+nt$n&,+fbTDZfbTABLEZ. E( t*@ fbTDZ$! #$,un,*nt$ -* u$ n+ *"$ ,& $#$n"&* !& $!t_ + n+.
JTML n+ "+n!&,$#* (+! $nt$#! n+ (+! $!p*"&+! '/(t&p($!. P*#* JTML6 n $!p*"&+! X 1 $!p*"&+. L+! $nt$#! - t*5! n+ p*#* JTML.
Su p#+@#*'* ,$5$ ($$# un *#" &)+ ,$ t$ t+ "+n "+nt$n&,+ $n JTML - ,$5$ $(&'&n*# (+! !&@u&$nt$! t*@! #$,un,*nt$fbTDZ6fbOPTIONZ6 fbULZ6 fbTJZ - fbLIZ. A,$'_! ,$5$ $(&'&n*# (+! t*@! u$ t$n@*n $!p*"&+!6 t*5! - $nt$# !+(*'$$0$'p(+ fPZ fbPZ%. S& !u p#+@#*'* $n"u$nt#* '_! ,$ un $!p*"&+ $n 5(*n"+6 $nt$# + t*56 $(&'&n*#_ $( $ "$!+. Su pt*'5& n "*'5&*#_ t+,*! (*! +"u##$n"&*! ,$ (+! !&@u&$nt$! p*t#+n$! 'n$'7n&"+! p+# $0$'p(+ nt&(,$% p+# p*t#+n$!p+# $0$'p(+ 241%. V$* (* !&@u&$nt$ t*5(* ,$ $ u&)*($n"&*!
.NPUT $N ;T-! :UTPUT $N ;T-! CARWCT$R Nt&(,$a 6 nt&(,$a 2< a 241a q 9A*"ut$a **"ut$a 1 3a 22 a _E*"ut$a $*"ut$a 2<1a 233a I*"ut$a &*"ut$a 2< a 23 a r `O*"ut$a +*"ut$a 211a 243a Ó 7U*"ut$a u*"ut$a 21 a 2 <a Ú /
$%emplo(
.nput(fJTMLZfTITLEZE0$'p(+fTITLEZfPZ fbPZfPZE!t+ $! un p_##* +
fbPZfTABLEZfTJZ T`tu(+ ,$ (* t*5(*fbTJZfTDZ Nt&(,$a*'$ B+0+t u*"ut$afbTDZ fbTABLEZ
fbJTMLZ
:utput(fJTMLZfTITLEZE0$'p(+fTITLEZfPZE!t+ $! un p_##* +fbPZfTABLEZfTJZ T`tu(+ ,$ (* t*5(*fbTRZfTDZ 2< aAME B+0+t 2 <fbTABLEZfbJTMLZ
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 120/499
Universidad de Puerto RicoBayamónJ Puerto Rico
Primeras Competencias de Programación'KKK
23perto
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 121/499
C*t$@+#`* E;PERTO UPRB P#+@#*''&n@ C+nP#+5($' !$t
Aut+# N$((&u, D. T+##$! Ap#&( 2 6 2
PIR=MIDES N0M/RICAS
D$!*##+(($ un p#+@#*'* u$ "+'p($t$ un* p&#_'&,$ "+(+"*n,+ un n/'$#+ ,$ un* + '_! "& #*! $n "*,* "*!&((*6 ,'+,+ t*( u$ "*,* "*!&((* "+nt$n@* (*! !u'*! ,$ (+! ,+! n/'$#+! ,$ (*! "*!&((* &n $#&+#$!. D$nt#+ ,$ (* p&#_'&,$ !$$!t*5($"$#_n un+! n/'$#+! @u`*! u$ *-u,*#_n * #$!+()$# $( p#+5($'*. L+! punt+! * "+n!&,$#*# !+n (+! !&@u&$nt$!
1. S$ &n,&"*#_n +" + % n/'$#+! p+# p&#_'&,$.2. L* p&#_'&,$ t&$n$ +" + % &(*!.3. P*#* "*,* &(* p+,#`* *5$# *!t* un '_ &'+ ,$ t#$! n/'$#+! p#$>$!t*5($"&,+!.4. N+ t+,*! (*! &(*! t&$n$n u$ t$n$# un n/'$#+ $!t*5($"&,+.. P+,#`*n *5$# *!t* un '_ &'+ ,$ t#$! 3% &(*! "+'p($t*'$nt$ $n 5(*n"+ p+# p&#_'&,$.
E0$'p(+ Pir*mide .nicial P&#_'&,$.&n%
Pir*mide Final P&#_'&,$.+ut%
43
''V 2<
1<124
+L
1<3
,
22&&&,
31 33''1 11
:
2:3:2<
4&'
=
1
44 14
''V
+L,
&&&, ''
&'
=
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 122/499
.nput(
!22B !! ! !*< ! $ !! ! ! ! !
! 1* ! 11 ! 2212 ! ! ! ! ! !! ! ! ! 3 ! ! !
:utput(
$3<22B 2!12$ 1!" 1!3*< "< $ ""3* 31 2* 22 332! 1* 1" 11 11 2212 < $ < 1" $ $ $ 3 1 * B
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 123/499
C*t$@+#`* E;PERTO UPRB P#+@#*''&n@ C+nt$!tP#+5($' !$t
Aut+# N$((&u, D. T+##$! Ap#&( 2 6 2<<<
$A AMENA7A
En un t*5($#+ ,$ *0$,#$8 !$ "+(+"*#_n p&$8*! #$p#$!$nt*,*! "+n (*! !&@u&$nt$! ($t#*! H6 6L6M - N. E!t#$p#$!$nt*n un #$-6 un* #$&n*6 un* t+##$6 un *( &( - un "*5*((+ *un u$ n+ n$"$!*#&*'$nt$ $n p#+@#*'* * "#$*# ,$"u*( p&$8* #$p#$!$nt* "*,* ($t#*. L+! punt+! * "+n!&,$#*# !+n (+! !&@u&$nt$!
1. Pu$,$n *5$# ,$ ,+! * t#$! "*!&((*! "+n $( )*(+# "$#+.2. S&$'p#$ *5#_ un* !+(u"&7n.3. C*!&((* )*"̀ * !$ #$p#$!$nt*#_ "+n un *!t$#&!"+ $n $( *#" &)+ ,$ $nt#*,*.4. L*! ($t#*! $!t*#_n $n $( *#" &)+ $n '*-/!"u(*!.. L*! p&$8*! !+n ,$ un !+(+ "+(+#a p+# (+ t*nt+ pu$,$n $!t*# p$@*,*! un*! ,$ (*! +t#*!.
E0$'p(+ Posición en el tablero
8 K
D K
! - N K
Resultado
8XR$-aD XD*'*a! XT+##$a- XC*5*((+aNXA( &(
.nput( T*5($#+.&n%
. e e e e e e ee e e e e e e ee e e e e e e eH e e e < e e ee e e e e e e e
e e e e e e ee e < e e e e e
L e M e N < e e
Output T*5($#+.+ut%
8XR$-aD XD*'*a! XT+##$a- XC*5*((+aNXA( &(
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 124/499
C*t$@+#`* E;PERTO
Aut +# Hu*n M. S+(_ S(+*n
UPRB P#+@#*''&n@ C+nt$!tP#+5($' !$t
Ap#&( 2 6 2<<<
DNS C*" $
Addre"" Re"olu!ion Simula!ion
L+! DNS D+'*&n N*'$ S$#)$#!% '*n$0*n (*! ,&#$""&+n$! ,*,*! ,$ *"u$#,+ * (* "(*!& &"*"&7n ,$( !&t&+un KAN (*! #$,$! !$ ,&!t#&5u-$n p+# !u5#$,$! - $!*! !u5#$,$! pu$,$n t$n$# +t#*! !u5#$,$!. En un* ,&#$""&"+'+ $!t* (*511<*p"."u5.up#."(u.$,u6 EDU $! (* "(*!& &"*"&7n ,$( !&t$6 CLU $! !u5n$t ,$ EDU6 UPR $! CLU6 CUB $! un !u5n$t ,$ UPR - $( (*511<*p" $! un !u5n$t ,$ CUB. C*,* ,&#$""&7n !$ "+n)&$#t$ $n unoctet un@#up+ ,$ 4 n n/'$#+! u$ #$p#$!$nt*n (* ,&#$""&7n #$*(% p*#$"&,+ * $!t$ 21 . 1. :.1.
L+! DNS p+!$$n un _#5+( "+n t+,*! (*! ,&#$""&+n$! u$ $ &!t$n $n !u _#$*. E((+! !$ $n"*#@*n ,$ t#*,u"&,&#$""&7n $n p*(*5#*! * un* ,&#$""&7n nu' #&"* - $!t*5($"$# (* "+n$""&7n. E!t$ p#+"$!+ !$ ((*'* #$!+(,&#$""&7n *,,#$!! #$!+(ut&+n%. L+! DNS ut&(&8*n t+,* !u '$'+#&* "+'+ un &n'$n!+ "*" $. L*! ,&#$""&!+(&"&t*,*! !$ 5u!"*n p#&'$#+ $n "*" $ - ,$ n+ $!t*# !$ 5u!"*n $n $( _#5+(.
U!t$, "#$*#_ un p#+@#*'* u$ ($$#_ ,+! *#" &)+! ,$ $nt#*,*6 un+ "+n (*! #*'*! ,$( _#5+( - +t#+ "+n (+! p$,&DNS )$# $0$'p(+%. C#$*#_ un "*" $ p*#* @u*#,*# (*! ,&#$""&+n$! '_! !+(&"&t*,*! *( DNS - @$n$#*#_,$ !*(&,*. $l *rbol tendr* un m*5imo de ramas4 $l tamaIo del cache ser* el primer n)mero GueapareQca en reGuest4in y puede ser de K S 'K+L direcciones46
Archivos de entrada(#atabase4in 2Contiene la estructura del *rbol6.EDU bINTER bCLU bbUPR bbbCUB bbbb(*511<*p" bbbCRC bbbCUTPO.MIL bNSA bNAVY bbNSKC bbbBISMAR l2.COM bYAJOO bLYCOS
ReGuest4in 2Eueue de las direcciones a procesar62"*C7>&upr&clu&eduC7>&upr&clu&eduIa4oo&comIa4oo&eduMarcos&lab12&prtc&netC7>&upr&clu&edu
:UTPUT4:UTCub&upr&clu&edu =ept4: $Cub&upr&clu&edu cac4e 4it: ?1Ia4oo&com =ept4: 2Ia4oo&edu Error $!$ Not foundC7>&upr&clu&edu cac4e 4it: ?2
.COM
LYCOSYAJOO
.EDU
NSKC
NSA NAVY
.MIL
DNS
LAB11<APC
UPR
CLU
CUTPOCUB
CRC
INTER
BISMAR2
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 125/499
(:
% pies
plataformas!
trompa!
piedra!
entrada cueva! 9
C*t$@+#`* E p$#t+ UPRB P#+@#*''&n@ C+nt$P#+5($' !$t
Aut+# J$"t+# - R&"*#,+ M*#t`n$8 Ap#&( 2 6 2<<
P#+@#*'* p#+@3. *#" &)+ ,$ $nt#*,* p#+@3.&n
archivo de salida( prog=4 out
Problema #3: El elefan!e *urio"o
Un $($ *nt$ $!t_ 'u- u#&+!+ p+# u$ un*! #*t*! *n "+n!t#u&,+ un* "u$)* $n $( +n,+ ,$ !u p+8+ ,$ *@u* #$!"*. P+# (+ u$ $!t$ * ,$"&,&,+ '$t$# (* t#+'p* $n $( *@u* - t*p*# (* $nt#*,* ,$ (* "u$)* "+n un* ,$ (*! p&$,#*! u$ !$ $n"u$nt#*n p+# $( _#$*.D$!* +#tun*,*'$nt$6 $($ *nt$ !$ $n"+nt#7 "+n ,+!
p#+5($'*! p#&'$#+6 "+'+ $( p+8+ $! 'u- p#+ un,+ n+ *("*n8* (* $nt#*,*6 p+# (+ u$ t$n,#_ u$ !+(t*# (* p&$,#*6 - !$@un,+6u$ n+ (* pu$,$ !+(t*# ,&#$"t*'$nt$6 p+# u$ (*! #*t*!6 "*n!*,*! ,$ t*nt+
5u"$*#6 *n "+n!t#u&,+ *,$'*! un*! p(*t* +#'*! &n"(&n*,*! $n (*! u$*"$n $!"*(* *( $nt#*# - !*(&# ,$( *@u*.
Cu*n,+ $( $($ *nt$ !u$(t* (* p&$,#*6 $!t_ *"u'u(*,* )$(+"&,*,6 - #$5+t* "u*n,+ " +"* "+n un* ,$ (*! p(*t* +#'*!.V$#,*,$#*'$nt$6 "*,* )$8 u$ (* p&$,#* "*$6 $!t* *"u'u(*,* )$(+"&,*,. P+# +t#+ (*,+6 (* p&$#,$ "u*n,+ !u5$ + "u*n,+ 'u$)$ p*#* (* &8 u&$#,* + (* ,$#$" *. O5!$#)$ $( !&@u&$nt$ $0$'p(+
L* p&$,#* "*$ 2d6" +"* "+n (* p(*t* +#'*6 !$ ,$!p(*8* 2d * (* ,$#$" *6- "u*n,+ p&$#,$ t+,* (* )$(+"&,*,6 )u$()$ * "*$#.
L* p&$,#* pu$,$ " +"*# "+n (*! p(*t* +#'*! p+# $n"&'* + p+# ,$5*0+. E( $ $"t+ $! !&$'p#$ $( '&!'+ (* p&$,#* pu$,$ !u5&# + '+)$#!$ p*#* (+! (*,+! (* '&!'* "*nt&,*, ,$ p&$! u$ 5*0*.
P#+5($'* D*,+ u$ $( $($ *nt$ pu$,$ un,&# (* t#+'p* $n "u*( u&$# p*#t$ ,$( p+8+ un+! 4 p&$!6 ,$t$#'&n$ ,$ ,+n,$ ,$5!+(t*# (* p&$,#* p*#* u$ $!t* t*p$ (* $nt#*,* ,$ (* "u$)*.
A!u'&#
1. E( p+8+ '&,$ p&$! ,$ *n" + p+# p&$! ,$ p#+ un,&,*,.2. E( $($ *nt$ pu$,$ '+)$# $( /(t&'+ p&$ ,$ (* t#+'p*6 p+# (+ u$ pu$,$6 ,*,+ u$ n+ !$ $n"u$nt#$ n&n@un* p(*t*
$n $( "*'&n+6 un,&# (* t#+'p* 3 p&$! - 1 p*#* (* &8 u&$#,* + (* ,$#$" *.3. E( *#" &)+ "+nt&$n$ un '*p* ,$( p+8+6 ,+n,$ (+! punt+! .% (($n*n (+! $!p*"&+! ,$ *@u*6 (*! p(*t* +#'*! !$
#$p#$!$nt*n "+n (d + [bd6 ,$p$n,&$n,+ ,$ (* ,&#$""&7n ,$ $!t*6 - (* $nt#*,* ,$ (* "u$)* !$ '*#"* "+n un* . L*$nt#*,* ,$ (* "u$)* !&$'p#$ $!t* $n $( +n,+.
4. S& (* p&$,#* p&$#,$ t+,* (* )$(+"&,*,6 - !$ $n"u$nt#* p+!*,* !+5#$ $( p&!+ + un* p(*t* +#'*6 n+ !$ 'u$)$ ,$ *. S& (* p&$,#* " +"* "+nt#* un* ,$ (*! p*#$,$!6 $!t* #$5+t* $n (* ,&#$""&7n "+nt#*#&*.:. S$ @*#*nt&8* u$ $( '*p* t&$n$ !+(u"&7n.. E( @&#*# (* t#+'p* !$ ,$5$ $!p$"& &"*# "+'+ * (* &8 u&$#,*6 ,$#$" *6 + n+ $! n$"$!*#&+.
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 126/499
D*t* ,$ $0$'p(+
4 4 4 4 4 4 4 44 4 4 4 4 4 4 44 4 4 4 4 4 4 44 4 4 4 4 4 X 44 4 4 4 4 4 4 44 4 4 X 4 4 4 44 4 4 4 4 < 4 44 4 4; 4 4 4 4
!*(&,*
,&!t*n"&* ,$( 5+#,$ d p#+ un,&,*, 4d@&#*# n+ $! n$"$!*#&+
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 127/499
Fecha 1: b M*-+ b 2<<< Nombre de la competencia lllllllllllllllllllllllll Categoría lllllllllll Universidad Un&). D$ Pu$#t+ R&"+6 R$"&nt+ ,$ B*-*'7nAutor I)_n H&' n$8 Tipo de competencia llllllllllllllllllllllllllllll Problema 1 Algoritmos llllllllllllllllllllllllllllllllllllll
6nput ;ile! dblog.inOu!pu! *ile: dblog,ou!Source *ile: dblog,>999?
Da!aba"e $ogging Table"
Problem #escription
M+!t ,*t*5*!$! *)$ * (+@@&n@ !-!t$' t *t ?$$p! t#*"? + *(( ,*t* '+,& &"*t&+n!. T $ (+@ @$n$#*
t &! !-!t$' *&,! &n t $ #$"+)$#- + t $ ,*t*5*!$ * t$# * "#*! .T $ ,*t* '+,& &"*t&+n! *#$ '*,$ t #+u@ "+n"u##$nt t#*n!*"t&+n! t *t * $"t t $ ,*t*5*!$. A t#*n!#$*,! ,*t*6 UPDATE! t $ ,*t* *n, !*)$! &t &n * !p*"$ &n t$'p+#*#- '$'+#-6 "*(($, * p*@$. t#*n!*"t&+n #$ u$!t! t *t *(( ,*t* up,*t$! &t *! '*,$ *#$ COMMITt$, &.$. #&tt$n t+ ,&!?%. Kt *t ,*t* &! #&tt$n t+ ,&!?6 t $ t#*n!*"t&+n *! END$,. In "*!$ + * ,*t*5*!$6 !-!t$' +# ,&!? &t &! p+!!&5($ t+ ABORT * t#*n!*"t&+n. T $ (+@@&n@ !-!t$' ?$$p! * " #+n+(+@&"*( (&!t +E*" (&!t #$"+#, &! + t $ +#'
LSN T-p$ T#*n!ID p*@$ID
E*" #$"+#, *! * un& u$ (+@ !$ u$n"$ nu'5$# LSN%. T $ t-p$ &! t $ *"t&+n 5$&n@ $ $t $ t#*n!*"t&+n up,*t$6 "+''&t6 $n, +# *5+#t%. T $trans . &! t $ &,$nt& &"*t&+n nu'5$# +# tt#*n!*"t&+n. T $ pa#e . &! t $ &,$nt& &"*t&+n nu'5$# +# t $ p*@$ 5$&n@ '+,& &$,.
T+ p#+)&,$ * !t*t&" &'*@$ + t $ ,*t*5*!$ !t*t$ 5$ +#$ * "#*! 6 t $ (+@@&n@ !-!t$' *(!+ ?$$p*"t&)$ t#*n!*"t&+n! *n, '+,& &$, p*@$!. T + t*5($! *#$ u!$, +# t &! pu#p+!$
• A ,&#t- p*@$ t*5($ DPT% ?$$p! t#*"? + t $ p*@$! &n u!$. It !t+#$! t $ pa#e . + t $ '+,& &$, p*@$ *n, t $ /S% 6 "*(($,rec/S% 6 + t $ &#!t (+@ #$"+#, t *t "*u!$, t $ *@$ t+ 5$"+'$ ,&#t-.On"$ t $ t#*n!*"t&+n t *t "*u!$! t $ p*@$ t+ 5$"+'$ ,&#t- $n,! +# &! *5+#t$,6 t $ p*@$ #$"+#, t*5($ &! $#*!$,.
• A t#*n!*"t&+n t*5($ TT% "+nt*&n! +n$ $nt#- +# $*" *"t&)$ t#*n!*"t&+n. T $ $nt#- "+trans ., t $ /S% + t $ '+!t #$"$nt (+@ #$"+#, +# t &! t#*n!*"t&+n "*(($,last/S% % *n, t $ status+ t $ t#*n!*"t&+n t *t &! &n p#+"$!! *"t&)$6 *5+#t$, +# "+''&t$,%. On"$ t $t#*n!*"t&+n &! $n,$, +# *5+#t$, &t! #$"+#, &n t $ t*5($ &! $#*!$,.
G&)$n t $ (+@ #$"+#,!6 #$"+n!t#u"t t $ ,&#t- p*@$ *n, t#*n!*"t&+n t*5($!. S + t $ p#+#$"+n!t#u"t! t $ t*5($!. Input &($ ,5(+@.&n "+nt*&n! t $ (+@ #$"+#,! &n t $ +#'*t
LSN t-p$ t#*n!ID p*@$ID
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 128/499
T $ +utput &($ ,5(+@.+ut ! +u(, "+nt*&n t $ ,&#t- p*@$ t*5($ *n, t#*n!*"t&+n t*5($ &n t $ +#'*t
/S% . " 2pa#e ., rec/S%),34, "" 2 (trans ., last/S%, status) ,34
N+t$!• A t#*n!*"t&+n &! *"t&)$ & &t *! '*,$ *n up,*t$ *n, &! n+t "+''&t$,6 *5+#t$,
+# $n,$,.• On(- up,*t$ #$"+#,! #$ u&#$ pa#e .s• A p*@$ &! n+t t*?$n + t $ ,&#t- p*@$ t*5($ unt&( *(( t#*n!*"t&+n! t *t '+,& &$, &t *#$ $&t
"+''&t$,b$n,$, +# *5+#t$,.
0ample .nput
1< up,*t$ T1 P12< "+''&t T13< $n, T14< up,*t$ T2 P2< up,*t$ T3 P3:< up,*t$ T2 P3
< *5+#t T2< up,*t$ T4 P< up,*t$ T4 P41<< "+''&t T3
Sam le O&$ &$
1< DPTX Q P16 1<% 6 TTX Q T16 1<6 *% 2< DPTX Q P16 1<% 6 TTX Q T16 2<6 "% 3< DPTX Q 6 TTX Q 4< DPTX Q P26 4<% 6 TTXQ T26 4<6 *% < DPTX Q P26 4<% 6 P36 <% 6 TTX Q T26 4<6 *% 6 T36 <6 *% :< DPTX Q P26 4<% 6 P36 <% 6 TTX Q T26 :<6 *% 6 T36 <6 *% < DPTX Q P26 4<% 6 P36 <% 6 TTX Q T26 :<6 5% 6 T36 <6 *% < DPTX Q P36 <% 6 P 6 <% 6 TTX Q T36 <6 *% 6 T46 <6 *% < DPTX Q P36 <% 6 P 6 <% 6 P46 <% 6 TTX Q T36 <6 *% 6 T46 <6 *% 1<< DPTX Q P36 <% 6 P 6 <% 6 P46 <% 6 TTX Q T36 1<<6 "% 6 T46 <6 *%
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 129/499
<Fecha 1: b M*-+ b 2<<< Nombre de la competencia lllllllllllllllllllllllll Categoría lllllllllll Universidad Un&). D$ Pu$#t+ R&"+6 R$"&nt+ ,$ B*-*'7nAutor I)_n H&' n$8 Tipo de competencia llllllllllllllllllllllllllllll Problema 2 Algoritmos llllllllllllllllllllllllllllllllllllll
Inpu! *ile: "ub"e!,inOu!pu! *ile: "ub"e!,ou!
0ource File( subset4M555
Sub"e!"
Problem #escription
G&)$n * !$t + " *#*"t$#!6 &n, *(( &t! !u5!$t!. T $ &nput &($ "+nt*&n! * (&!t + " *#*"t$# 5- !p*"$!. T $ +utput &(( "+nt*&n *(( t $ p+!!&5($ !u5!$t!a +n$ !u5!$t p$# (&n$.
0ample .nput
a b c
0ample :utput
\ a b c d ]\ a b c ]\ a b d ]\ a c d ]\ b c d ]\ a b ]\ a c ]\ a d ]\ b c ]\ b d ]\ c d ]\ a ]\ b ]
\ c ]\ d ]\ ]
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 130/499
Fecha 1: b M*-+ b 2<<< Nombre de la competencia lllllllllllllllllllllllll Categoría lllllllllll Universidad Un&). D$ Pu$#t+ R&"+6 R$"&nt+ ,$ B*-*'7nAutor I)_n H&' n$8 Tipo de competencia llllllllllllllllllllllllllllll Problema 3 Algoritmos llllllllllllllllllllllllllllllllllllll
6ord Pu11le @@
6nput ;ile! puzzle2.inOu!pu! *ile: pu11le4,ou!
ource ;ile! puzzle2.=>>>?
PuQQle #escription
In * +#, pu88($ -+u *#$ @&)$n * (&!t + +#,! *n, * @#&, + ($tt$#!. T $ +50$"t&)$ + t $t+ &n, *(( (&!t$, +#,! $'5$,,$, &n t $ @#&, + ($tt$#!. T $ +#,! "*n 5$ +un, +#&8+nt*((-6 )$#t&"*,&*@+n*((-. In t &! )*#&*t&+n + t $ @*'$6 +#,! "*n *(!+ *pp$*# t &!t$, !$$ &@u#$ 5$(+ %.
M*?$ * p#+@#*' t *t &(( !+()$ * +#, pu88($. Y+u# p#+@#*' 'u!t &n, *(( +#,! p#$!$nt *+utput t $ p+!&t&+n + $*" ($tt$# + t $ +#, +n t $ @#&,. T $ &nput &($ "+n!&!t! + t $ ,&'$n!&+@#&,6 t $ @#&, + ($tt$#! *n, * (&!t + +#,! t+ &n,.
T $ +utput &($ &(( 5$ t $ (&!t + ($tt$#!6 +((+ $, 5- t $ "++#,&n*t$ + $)$#- ($tt$# + t $ +t $ !t#&n@ [n+t +un,\.
t c n 8 l p
D i s u r o e o A t
o b A r e 4
d l m 4 * 9
e E e l l o
0ample .nput
:TCJNLPGKISUR OEO TGOB REJ9L@A96A LLBPu88($
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 131/499
+#, p#+5($'$((+t &!t$,*##*-&nput+utput
Sam le O&$ &$
pu88($ <6 % 16 4% 26 3% 36 2% 46 1% 6 <%+#, 16 1% 26 2% 36 3% 46 4%
p#+5($' n+t +un,$((+ 6 1% 16 1% 6 2% 6 3% 6 4%t &!t$, <6 <% 16 1% 16 2% 16 3% 26 4% 36 4% 46 4%*##*- n+t +un,
&nput n+t +un,+utput n+t +un,
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 132/499
T $ +utput &($ "+n!&!t! + t $ nu'$#&" !$ u$n"$ +((+ $, 5- t $ (&!t + n*'$! t *t '*t" $, t $!$ u$n"$ +# t $ '$!!*@$ [N+ M*t" $! F+un,\.
Sam le In &$
1<V$($86 C*#(+!T+##$!6 An*H+(&$6 An@$(&n*L+p$86 M*#&5$(L*@u$##$6 T+n-L+p$#$n*6 M*#t *S*nt+!6 B$n0*'`n+#@6 H*'$!(&n@$#6 J$&,&u$!t$((6 E,u*#,+4234:: 3
Sam le O&$ &$
S$ u$n"$ 234R$!u(t N+ M*t" $! F+un,
S$ u$n"$ :
R$!u(t!L+p$86 M*#&5$(L+p$#$n*6 M*#t *+#@6 H*'$!
S$ u$n"$ : 3R$!u(t!L+p$#$n*6 M*#t *
S$ u$n"$ R$!u(t!
H+(&$6 An@$(&n*L+p$86 M*#&5$(L*@u$##$6 T+n-L+p$#$n*6 M*#t *S*nt+!6 B$n0*'`n+#@6 H*'$!(&n@$#6 J$&,&
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 133/499
Universidad de Puerto RicoBayamónJ Puerto Rico
Competencias de Programación &VVV23perto
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 134/499
C*t$@+#`* E p$#t+ CUB P#+@#*''&n@ C+nP#+5($' S$t
Aut +# P#+ . Hu*n S+(_ S(+*n M*- 2 6 1
Terran vs4 "ergs
Terran Me%%age De)- .erUn @ +!t $!t_ $ p(+#*n,+ $( !$"t+# A(p * 4 ,$( p(*n$t* ; $n p_#!$" 2:. J*"$ ,`*! u$
(+! T$##*n! n+ !*5$n ,$ !u p*#*,$#+ *!t* u$ un '$n!*0$ $n "(*)$ ($! (($@7.
D$"& #$ $( '$n!*0$ ,$ (+! T$##*n! ut&(&8*n,+ ,$ pri'ate key $( )*(+# #$*( 14.2 . E( p#&'$#)*(+# u$ !$ #$"&5$ $n $( *#" &)+ $! $( public key . C+n $( pu5(&" ?$- !$ +5t&$n$ (* p#&'$#* ($t#* ,$(*( *5$t+ $n '*-/!"u(* A%. E( $!p*"&+ - $( punt+ !+n (*! ,+! /(t&'*! ($t#*! $( p#+t+"+(+ (u$@+ ,$ %. L* 7#'u(* p*#* ,$"& #*# $( '$n!*0$ $! "*("u(*,* ut&(&8*n,+ $( )*(+# $n)&*,+ - $( pri'ate key . L*t*5(* p*#* ,$"& #*# "*,* )*(+# #$!u(t*nt$ !$ ,$t$#'&n* ut&(&8*n,+ $( pu5(&" ?$- ,$ 5*!$.
N+t* En (+! '$n!*0$! (+! t$##*n! n+ $!t_n ut&(&8*n,+ $n $!t$ p#+t+"+(+ n/'$#+!. u&$#$ ,$"&# uu&$#$n ,$"&# 14 (+ $n)`*n CATORCE%.
Programe un deci7rador del código enviado por el ghost4 UtiliQara de input el archivo dec4enc ypresentar* el output en pantalla4
$%emplo(
.nput(&=+4 &V,,4 K '& &4 &VV 4KK
:utput(" $ R 9
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 135/499
C*t$@+#&* E;PERTO CUB P#+@#*''&n@ C+ntP#+5($' !$t
Aut +# USACO M*- 2 6 1
S0PERPRIME RI#
But" $#&n@ F*#'$# H+ n ! "+ ! *( *-! -&$(,! t $ 5$!t p#&'$ #&5. Y+u "*n t$(( p#&'$ #&5! 5- (+t $ ,&@&t! (+)&n@(- !t*'p$, *"#+!! t $'6 +n$ 5- +n$6 5- FH *n, t $ USDA. F*#'$# H+ n $n!u#$! pu#" *!$# + &! p#&'$ #&5! @$t! #$*((- p#&'$ #&5!5$"*u!$ $n !(&"$, #+' t $ #&@ t6 t $ nu'5$#&5! "+nt&nu$ t+ !t*- p#&'$ #&@ t ,+ n t+ t $ (*!t #&56 $.@.
3 3 1
T $ !$t + #&5! 331 &! p#&'$a t $ t #$$ #&5! 33 *#$ p#&'$a t $ t + #&5! 3 *#$ p#&'$6 *n,6 + "+(*!t #&56 6 &! p#&'$. T $ nu'5$# 331 &! "*(($, * !up$#p#&'$ + ($n@t 4.
TECJNICAL CONSTRAINTS
1. F+# t $ pu#p+!$! + p#&'$ #&5!6 t $ nu'5$# 1 5- &t!$( % &! n+t * p#&'$ nu'5$#.
2. T $ nu'5$# + #&5! N !*t&! &$! 1sNs .
3. E &t & t $ nu'5$# + #&5! &! $nt$#$, *! <.
K#&t$ * p#+@#*' t *t *""$pt! * nu'5$# + #&5! 1.. % *n, t $n p#&nt! *(( t $ !up$#p#&'$! + t *t ($nE &t & t $ nu'5$# + #&5! $nt$#$, &! <.
E;AMPLE
Nu'5$# + ,&@&t! 4
2333 233 23 3 23 2 2 3 311 313 3 33 3 3 3 3 3 3 1 3 331 333 3 3
TEST CASES
N X N X
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 136/499
C*t$@+#&* E;PERTO CUB P#+@#*''&n@ C+ntP#+5($' !$t
Aut +# USACO M*- 2 61
N0M#ER TRIAN+$ES 3 1 < 2 4 4 4 2 :
Fig4 &
F&@u#$ 1 ! + ! * nu'5$# t#&*n@($. K#&t$ * p#+@#*' t *t "*("u(*t$! t $ &@ $!t !u' + nu'5$#! p*!!$, +n *t *t !t*#t! *t t $ t+p *n, $n,! !+'$ $#$ +n t $ 5*!$. E*" !t$p "*n @+ $&t $# ,&*@+n*((- ,+ n t+ t $ ($ t +# ,&*@+n*(,+ n t+ t $ #&@ t.
In t $ !*'p($ ! + n &n F&@. 16 t $ #+ut$ #+' t+ 3 t+ t+ t+ p#+,u"$! t $ &@ $!t !u' 3<.
T$C;N.CA! C:N0TRA.NT0
1. Put -+u# &nput &($ +# $*" t$!t "*!$ &n * t$ t &($ n*'$, NUMBER.IN.
2. T $ nu'5$# + #+ ! &n t $ t#&*n@($ &! Z 1 5ut fX 1<<.
3. T $ nu'5$#! &n t $ t#&*n@($ *#$ *(( &nt$@$#! 5$t $$n < *n, &n"(u!&)$.
0A-P!$ RUN
NU-B$R4.N *pp$*#! *! +((+ ! T $ &#!t nu'5$# &! t $ nu'5$# + #+ ! &n t $ t#&*n@+((+ $, 5- t $ nu'5$#! &n $*" #+ . T u! t $ t#&*n@($ &n F&@ 1 ! +u(, 5$ !t+#$, &nNU-B$R4.N *!+((+ !
3 1 <2 4 44 2 :
T $ *n! $# &!=K
T$0T CA0$0A t$!t "*!$ &(( 5$ !upp(&$, 5- -+u# t$*" $# +# "++#,&n*t+#.
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 137/499
0:!UC.:N$02. Nu'5$# T#&*n@($!
NU-B$R4.N14: 1:4 4 4: 1 31 14 11 3 2
: 21 < 4: : : : 2 1 4< 1
1 3 1 1< 3 1 < 1: :: 4 3< 1 22 2 1 4< 44 3 44 3 4 22 1: 2 43 21 2 1 4
3< 1 1 2 33 4 3 : :: 43 4:3 3: 12 43 2: 4 2: 4 2 23 11 :1 : 42 3 2 :1 3: 2 1 24 1 1: :: 14 1< :1 : 2 3 : 3 4 44 3 2<
NUMBER.OUT:
A @++, p#+@#*' ! +u(, 5$ *5($ t+ !+()$ t $ "*!$ $#$ t $ nu'5$# + #+ ! &! 1<< n$*#(- *! *!t *! t &"*!$.
I p+!!&5($6 *!? t $ !tu,$nt t+ @$n$#*t$ * #*n,+' t#&*n@($ &t 1<< #+ ! *n, !$$ & &!b $# p#+@!t&(( #un &t &n t $ t&'$ (&'&t.
A p#+@#*' t *t t#&$! *(( p+!!&5($ p*t ! @+&n@ +# *#, &(( n$)$# '*?$ &t. It 'u!t +#? 5*"? *#,!.
0uperprime Rib
N X
233 3323 3332 33 333 3333 3 133 3 313 3 33
N X
233 332 33 333 3333 3 133
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 138/499
C*t$@+#&* E;PERTO CUB P#+@#*''&n@ C+ntP#+5($' !$t
Aut +# USACO M*- 2 61
7ERO S0M
C+n!&,$# t $ !$ u$n"$ + ,&@&t! #+' 1 t #+u@ N $#$ NX % &n &n"#$*!&n@ +#,$# 1 2 N *n, &n!$#t $&t $# * % +# *,,&t&+n +# * >% +# !u5t#*"t&+n +# * % Q5(*n? t+ #un t $ ,& N+ !u' t $ #$!u(t *n, !$$ & -+u @$t 8$#+.
K#&t$ * p#+@#*' t *t &(( &n, *(( !$ u$n"$! + ($n@t N t *t p#+,u"$ * ERO SUM.
Test Case &
Input Output 1 2 > 3 4 > > : X <
1 2 > 3 > 4 : > X <1 > 2 3 4 > : > X <1 > 2 > 3 > 4 > : X <1 > 23 > 4 : X <1 > 23 > 4 : X <
T$!t C*!$ 21 2 3 4 = = : = X <1 2 3 = 4 = : = X <1 2 = 3 4 : = = X <1 2 = 3 = 4 = = : X <1 23 = 4 : X <1 = 2 3 = 4 = : = X <1 = 2 > 3 4 > :> X <1 = 2 = 3 4 = : = X <1 = 23 = 4 : X <12 = 34 = : X <
Y+u '*- t$!t t &! p#+@#*' 5- $nt$#&n@ t $ &nt$@$# #+' t $ ?$-5+*#,.U!$ +n$ #$p+#t +#' +# $*" !tu,$nt%.
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 139/499
Fecha llllbllllb1 Nombre de la competencia llllllllllllllll Categoría $5perto Universidad( CUBYYYYY lllllllllllllAutor lllllllllllll Tipo de competenciaProblema lllll Algoritmos lllllllllllllllllllllllll
*RIDA T5E B2T5
I! F#&,*- t $ 13t #$*((- *n unu!u*( $)$nth T *t &!6 ,+$! t $ 13t + t $ '+nt (*n, +n * F#&,*- ($!!+ t$n t *n +n *n- +t $# ,*- + t $ $$?h T+ *n! $# t &! u$!t&+n6 #&t$ * p#+@#*' t *t &(( "+'put$ t#$ u$n"- t *t t $ 13t + $*" '+nt (*n,! +n Sun,*-6 M+n,*-6 Tu$!,*-6 K$,n$!,*-6 T u#!,*-6F#&,*-6 *n, S*tu#,*- +)$# * @&)$n p$#&+, + N -$*#!. T $ t&'$ p$#&+, t+ t$!t &(( 5$ #+' H*nu*t+ D$"$'5$# 316 1 << N>1 +# *n- nu'5$# + -$*#! N. T $#$ *#$ * $ *"t! -+u n$$, t+ ?n+ 5$ +#-+u "*n !+()$ t &! p#+5($'
1. H*nu*#- 16 1 << *! +n * M+n,*-.
2. T &#t- ,*-! *! S$pt$'5$#6 Ap#&(6 Hun$6 *n, N+)$'5$#6 *(( t $ #$!t *)$ 31 $ "$pt +# F$5&" *! 2 $ "$pt &n ($*p -$*#! $n &t *! 2 .
3. E)$#- -$*# $)$n(- ,&)&!&5($ 5- 4 &! * ($*p -$*# 1 2 X 4e4 !+ 1 2 &(( 5$ * ($*p -$*#6 5-$*# 1 << &! n+t * ($*p -$*#%
4. Ru($ 3 ,+$! n+t +(, +# "$ntu#- -$*#!. C$ntu#- -$*#! ,&)&!&5($ 5- 4<< *#$ ($*p -$*#!6 *(( n+t. T u! t $ "$ntu#- -$*#! 1 <<6 1 <<6 1 << *n, 21<< *#$ n+t ($*p -$*#!6 5ut 2<<< &! * ($*p -
T$!t -+u# p#+@#*' +# NX2< *n, NX4<<.
N:T$( T+ '*?$ &t *&# +# $)$#-+n$6 -+u '*- n+t u!$ *n- 5u&(t>&n ,*t$ un"t&+n! &n -+u# "(*n@u*@$.
T$0T CA0$ &Ent$# t $ nu'5$# + -$*#! Nh'KFROM HAN 16 1 << TO DECEMBER 316 1 1 TJE 13TJ OF TJE MONTJ LANDS ON
#A :F T.-$0
SUNDAY 33
-:N#A =+
TUESDAY 33KEDNESDAY 3TJURSDAY 3FRIDAY 34SATURDAY 3:I * !+(ut&+n &n"#$'$nt! ,*- 5- ,*- &n!t$*, + '+nt 5- '+nt &t &(( t*?$ 3< t&'$! (+n@$# t+ $ *'&n$4<< -$*#! *n, '&@ t #un t++ (+n@.%
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 140/499
Universidad de Puerto RicoBayamónJ Puerto Rico
Competencias de Programación &VVVIntermedio
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 141/499
C*t$@+#&* INTERMEDIO CUB P#+@#*#''&n@ C+nt$ P#+5($' !$tAut +# N$((&u, D. T+##$! M*- 2 6 1
PRO+RAM $ISTIN+
Un* "u*(&,*, u$ p*#$"$ ,&!'&nu&# "+n $( u!+ ,$ (+! ($n@u*0$! ,$ p#+@#*'*"&7n $n *'PC $! (* &'p#$!&7n $n p*p$( ,$ un [!+u#"$ p#+@#*'\ u$ pu$,* (&!t*# $( "7,&@+ "+n $nu'$#*(`n$* - $n"*5$8*'&$nt+ $n "*,* p_@&n*. E!t* +p"&7n !$ u!* 'u" + $n *'5&$nt$! ,$ [M*&n #*'(&!t*,+! ,$ p#+@#*'*! (*#@+! u$ !$ &'p#&'$n "+n (* +p"&7n [!.0T.N9Z p*#* p+,$# $ *'&n*#,$t$n&,*'$nt$ $( p#+@#*'*6 !u! )*#&*5($! $ &n"(u!+ (+! '$n!*0$! ,$ $##+#$!.
L* +p"&7n ,$ [!.0T.N9 \ n+ !+(+ @$n$#* un (&!t*,+ "+n $n"*5$8*'&$nt+ p+# p_@$nu'$#*"&7n p+# (`n$*6 !&n+ u$ t*'5& n (&!t* (+! $##+#$! ,$ !&nt* &! !& $! u$ $ &!t$ *(@(`n$* !$ $n"u$nt#*. T*'5& n pu$,$ @$n$#*# un (&!t*,+ ,$ )*#&*5($!6 $n ,+n,$ !$ ,$ &n$n6 $n
'+,& &"*n - $n ,+n,$ !$ ut&(&8*n. E!t+ $#* ,$ @#*n *-u,* * (+! p#+@#*'*,+#$! ,$ *'5&$nt$ [M*- t*'5& n "+n!&,$#+ u$ pu$,$ !$# ,$ *-u,* * (+! p#+@#*'*,+#$! ,$ *'5&$nt$PC.
PR:B!$-A
J*@* un p#+@#*'* u$ ($* un p#+@#*'* ,$ P*!"*( ,$ $nt#*,* - @$n$#$ ,$ !*(&,* un$n"*5$8*'&$nt+ p+# p_@&n* - $nu'$#$ un* (`n$* ,$ "7,&@+ u$ t$n@* $( p#+@#*'*.
PUNT:0 .-P:RTANT$0
T$n@* $n '$nt$ (+ !&@u&$nt$
1. E( p#+@#*'* ,$5$ &'p#&'&#!$ *!t* (`n$*! p+# p_@&n*.
2. En (* p#&'$#* p*#t$ ,$( $n"*5$8*'&$nt+ !$ ut&(&8*#_#* $( n+'5#$ ,$( p#+@#*'* pu$!t+ ,$!puPR:9RA- "+n (* $ t$n"&7nPA0.
3. En (* !$@un,* p*#t$ !$ &n"(u&#_(* $" * - +#* ,$ (* "+'put*,+#* - $( ,`* ,$ (* !$'*n*.4. F&n*('$nt$ $n (* t$#"$#* p*#t$ !$ )* $nu'$#*n,+ (*! p_@&n*!.
. D$!pu ! ,$ $nu'$#*# $n "*,* (`n$*6 !$ p+n$ $( "*#*"t$# ["+(+n\ % - !$ ,$0* p+# (+ '$n+! $n un$!p*"&+ $n 5(*n"+.
:. En un* /(t&'* p_@&n* !$ )* * @$n$#*# un (&!t*,+ ,$ )*#&*5($! p+# +#,$n *( *5 t&"+.
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 142/499
$8$-P!: #$ C:RR.#A
Ut&(&8*n,+ ,$ $0$'p(+ $( !&@u&$nt$ "7,&@+
P5K 56M newton -input, output/T
CKN;'
Epsilon % leD*T
Q65Number, root, s root: realT
>E 9N5EPE6'
writelnTwrite-^Enter new number -! to uit/: ^/Tread -number/T
9J number % ! 'LEN >E 9Nriteln-number:12:*, !&!:12:*/T
EN=E ;E 9J number V ! 'LEN >E 9N
riteln-^...E55K5: number V !_/T
EN=E ;E >E 9N
; root :% s rt-number/Twriteln-number: 12:*, s root: 12:*/TwritelnT
root :% 1T5EPE6'
root :%-numberAroot F root/A2Twriteln-root:2$:*,
1!!.abs-root ` s root/As root:12:2,^ _/
7N'9 abs-numberAs r-root/ ` 1/ VepsilonTEN=
7N'9 number % !EN=&
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 143/499
S$ ,$5$ @$n$#*# $( !&@u&$nt$ (&!t*,+
neDton.pas at MaF 29G 1999 10#13#25 +age# 1
1: P5K 56M newton -input, output/T 2:
3: CKN;'$: Epsilon % leD*T":*: Q65<: Number, root, s root : realT:B: >E 9N
1!: 5EPE6' 11: writelnT
12: write-^Enter new number -! to uit/: ^/T 13: read-number/T 1$: 1": 9J number %! 'LEN >E 9N 1*: riteln-number:12:*, !&!:12:*/T 1<: EN= 1 : E ;E 9J number V! 'LEN >E 9N 1B: riteln-^...E55K5: number V!_/T 2!: EN= 21: E ;E >E 9N 22: ; root :%s rt-number/T
23: writeln-number:12:*, s root: 12:*/: 2$: writelnT 2": 2*: root :% 1T 2<: 5EPE6' 2 : root :% -numberAroot F root/A2T 2B: writeln-root:2$:*, 3!: 1!!.abs-root ` s root/As root:12:2, 31: ^ _/ 32: 7N'9 abs-numberAs r-root/ ` 1/ VepsilonT 33: EN= 3$: 7N'9 number % ! 3": EN=&
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 144/499
Ne?ton4pas 0at -ay 'VJ &VVV &K(&=(' Page('CR:00 R$F$R$NC$
epsilon !!!$ !!32number !!!< !!13 !!1" !!1* !!1 !!22 !!23 !!2 !!32 !!3$root !!!< !!22 !!23 !!2* !!2 !!2 !!2 !!2B !!3! !!32s root !!!< !!3! !!3!
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 145/499
Fecha 2 b M*-+ b 1 Nombre de la competencia lllllllllllllllllllllllll Categoría Int$#'$,&+ Universidad Un&). D$ Pu$#t+ R&"+6 R$"&nt+ ,$ B*-*'7nAutor I)_n H&' n$8 Tipo de competencia llllllllllllllllllllllllllllll Problema Algoritmos llllllllllllllllllllllllllllllllllllll
Telep one Direc!or% Searc
Problem #escription
S+'$ )+&"$ '*&( !-!t$'! *((+ u!$#! t+ !$*#" +# p +n$ nu'5$#! + +t $# #$@&!t$#$, u!$#! + !-!t$'. T+ ,+ !+6 +n$ 'u!t !p$(( t $ n*'$ +# * p#$ & + t $ n*'$ + t $ p$#!+n t+ "*((. T &! &*""+'p(&! $, 5- p#$!!&n@ t $ ?$- nu'5$# "+##$!p+n,&n@ t+ $*" ($tt$# + t $ p#$ & .
U!$ t $ +((+ &n@ ,&*@#*' t+ '*p nu'5$#! +n t $ ?$-p*, t+ ($tt$#!.
K#&t$ * p#+@#*' t *t &n,! *(( n*'$! &n t $ ,&#$"t+#- t *t '*t" * @&)$n n*'$ p#$ & . T $ p#&! @&)$n *! * !$ u$n"$ + ?$-p*, p#$!!$!. B$@&n 5- '*t" &n@ t $ (*!t n*'$ *n, t $n t $ &#!t n*'$.
T $ &nput &(( "+n!&!t +
• Nu'5$# + n*'$!b#$"+#,! &n t $ ,&"t&+n*#-• L&!t + n*'$! &n t $ ,&"t&+n*#-• Nu'5$# + ?$-p*, nu'$#&" !$ u$n"$!• Nu'$#&" !$ u$n"$! +n$ p$# (&n$%.
T $ &nput &(( "+n!&!t + * &($ n*'$,Tel4in
T $ +utput "+n!&!t + t $ 'u'$#&" !$ u$n"$ +((+ $, 5- t $ (&!t + n*'$! t *t '*t" $, t $ !$ u$n"$ +#t $ '$!!*@$ [N+ M*t" $! F+un,\.
1$!p*"&+
2ABC
3DEF
4GJI H L
:MNO
P RS TUV K;Y
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 146/499
0ample .nput
1<V$($86 C*#(+!T+##$!6 An*H+(&$6 An@$(&n*L+p$86 M*#&5$(L*@u$##$6 T+n-L+p$#$n*6 M*#t *S*nt+!6 B$n0*'`n+#@6 H*'$!(&n@$#6 J$&,&u$!t$((6 E,u*#,+4234:: 3
0ample :utput
S$ u$n"$ 234R$!u(t N+ M*t" $! F+un,
S$ u$n"$ :R$!u(t!L+p$86 M*#&5$(L+p$#$n*6 M*#t *+#@6 H*'$!
S$ u$n"$ : 3R$!u(t!L+p$#$n*6 M*#t *
S$ u$n"$ R$!u(t!H+(&$6 An@$(&n*L+p$86 M*#&5$(L*@u$##$6 T+n-L+p$#$n*6 M*#t *S*nt+!6 B$n0*'`n+#@6 H*'$!(&n@$#6 J$&,&
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 147/499
C*t$@+#&* INTERMEDIO CUB P#+@#*''&n@ C+nt$!tP#+5($' !$t
Aut +# USACO M*- 2 61
Super Roman Numeral" ol"!ad B FGY+u )$ $*#, t $ !t+#- + R+'*n! (&?$ M&,*! + *, t $ gG+(,$n T+u" .M&,*! *! n+ ++(
*n, !+(, &! @+(, +# (+t! + '+n$-. T $ t#*,&t&+n*( R+'*n nu'$#*(! p#+)$, &n"+n)$n&$nt +#$ p#$!!&n@ t $ )*(u$ + &! +#tun$6 &" #*n@$, &nt+ t $ '&((&+n!. J$ &n)$nt$, Sup$# R+'*n Nu'$#*(!.
Sup$# R+'*n Nu'$#*(! +((+ t $ t#*,&t&+n*( #u($! +# R+'*n nu'$#*(! 5ut *)$ '*n- '+#$ !&n@($>" *#*"t$#)*(u$!. C+n!&,$# t $ t#*,&t&+n*( R+'*n nu'$#*( )*(u$!6 ! + n $#$ &t t $ !&n@($ ($tt$# *n, t $ ,$"&'*( nu'5$# &t#$p#$!$nt!
. 1 ! < - 1<<< / C 1<< O 1< # <<
A! '*n- *! t #$$ + t $ !*'$ '*#?! t *t #$p#$!$nt 1< n '*- 5$ p(*"$, "+n!$"ut&)$(-
... &! 3 CCC &! 3<<
M*#?! t *t *#$ e 1< n *#$ n$)$# u!$, "+n!$"ut&)$(-.G$n$#*((- &t t $ $ "$pt&+n + t $ n$ t #u($%6'*#?! *#$ "+nn$"t$, t+@$t $# *n, #&tt$n &n ,$!"$n,&n@ +#,$#
CC!O... X 1<< 1<< < 1< 1 1 1 X 2:3 S+'$t&'$!6 * '*#? t *t #$p#$!$nt! 1< n &! p(*"$, 5$ +#$ * '*#? + +n$ + t $ t + n$ t &@ $# )*(u$! . 5$ +#$/
+#OaO 5$ +#$! +#Ca $t".%. In t &! "*!$6 t $ )*(u$ + t $ !'*(($# '*#? &! SUBTRACTED #+' t $ '*#? &t p#$"$,$!
./ X 4 .O X O! X 4<
But "+'p+un, '*#?! (&?$O#6.C6 *n,O- *#$ n+t ($@*(6 !&n"$ t $ !'*(($# '*#? &! t++ 'u" !'*(($# t *n t $(*#@$# +n$. F+#O# #+n@ +# 4 <%6 +n$ +u(, u!$C#OCa +# IC #+n@ +# %6 +n$ +u(, u!$OC.Oa +#O-#+n@ +# <%6 +n$ +u(, u!$C-OC .
R$@#$tt*5(-6 &n !t*n,*#, R+'*n nu'$#*(!6 nu'5$#! (&?$ 1<6<<< *#$ #$p#$!$nt$, *!---------- . InSup$# R+'*n Nu'$#*(!6 t $ t*5($ + '*#?! &! $ t$n,$,
. 1 ! < - 16<<< R <6<<< U 16<<<6<<< N <6<<<6<<< / C 1<< P 6<<< 0 1<<6<<< B 6<<<6<<< 1<<6<<<6<<<
; &K D KK &KJKKK T KKJKKK K &KJKKKJKKKKKJKKKJKKK
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 148/499
Nu'5$#! @#$*t$# t *n 1<< '&((&+n *#$ n+ $*!&(- $ p#$!!&5($. K#&t$ * p#+@#*' t *t #$*,! n+,$"&'*( nu'5$#! +n$ p$# (&n$% #+' t $ &($.NPUT4#AT *n, p#&nt! t $ Sup$# R+'*n Nu'$#*($ u&)*($nt. It &! p#+'&!$, t *t t $ &nput ,*t* &(( #$ u&#$ *n *n! $# t *t &! #$p#$!$nt*5($ u!&n@#u($!. St+p -+u# p#+@#*' $n t $ &nput nu'5$# &! * <.
0:!UC.:N$0
0uper Roman Numerals [DolstadJ &VV \
SAMPLE INPUT &($ INPUT.DAT%
111234 :<
SAMPLE OUTPUT
1 ;VIII1 MCM;CVII1234 : KUUSSS RPDCL;;VIII
TEST DATA SET 1
11: 4321
11111<
>
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 149/499
C*t$@+#&* INTERMEDIO CUB P#+@#*''&n@ C+P#+5($' !$t
Aut +# USACO M*- 2 61
*ACTORIA$S
T $ *"t+#&*( + *n &nt$@$# n6 #&tt$n nW6 &! t $ p#+,u"t + *(( t $ &nt$@$#! #+' 1 t #+u@ &n"(u!&)$u&"?(- 5$"+'$! )$#- (*#@$ 13W &! t++ (*#@$ t+ !t+#$ &n * 32>5&t &nt$@$# +n '+!t "+'put$#!6 *n, <W &! t++(+*t&n@>p+&nt )*#&*5($!. Y+u# t*!? &! t+ &n, t $ #&@ t'+!t n+n>8$#+ ,&@&t + nW. F+# $ *'p($6 W X 1 e 2!+ t $ #&@ t'+!t n+n>8$#+ ,&@&t + W &! 2. A(!+6 W X 1 e 2 e 3 e 4 e e : e X <4<6 !+ t $ #&@ t'+!t n+n>8$#&! 4.
Input
An &nt$@$# n6 5$t $$n 1 *n, 1<<< &n"(u!&)$.
Output
T $ #&@ t'+!t n+n>8$#+ ,&@&t + nW
TEST CASE 1
Input
Output2>TEST CASE 2Input
Output4
TEST CASE 3Input
1<<<Output2
T &! p#+@#*' '*- 5$ t$!t$, 5- $nt$#&n@ &n &nput #+' t $ ?$-5+*#,.
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 150/499
C*t$@+#&* INTERMEDIO CUB P#+@#*''&n@ C+nt$!tP#+5($' !$t
Aut +# USACO M*- 2 61
PRIME PA$INDROMEST $ nu'5$# 1 1 &! * p#&'$ p*(&n,#+'$ 5$"*u!$ &t &! 5+t * p#&'$ nu'5$# *n, * p*(&n,#+'$ &t &! t $ !*'$
nu'5$# $n #$*, +# *#, *! 5*"? *#,%. K#&t$ * p#+@#*' t *t &n,! *(( p#&'$ p*(&n,#+'$! 5$t $$n t + nu'5$#! * *n, 5. Y+u '*- *!!u'$ t *t * *n, 5 *#$ 5$t $$n 1 *n, 326<<<.
T$!t -+u# p#+@#*' &t *65 X 16 1<<< *n, *65 X1<<<6 32<<<
Test Case
*65 X 161<<<
PR.-$ PA!.N#R:-$0 B$T@$$N & AN# &KKK
2 3 111<1 131 1 1 1 1 1 1
313 3 3 3 3 3 3 2 1 2
Test Case '
*65 X 1<<<<6 32<<<>
PR.-$ PA!.N#R:-$0 B$T@$$N &KKK AN# ='KKK
1<3<1 1< <1 1<:<1 11311 11411 12421 12 21 12 21 13331 13 31 13 3114341 14 41 1 4 1 1 1 1:<:1 1:3:1 1: :1 1:::1 1 4 1 1 1 1 1 1
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 151/499
Universidad de Puerto RicoBayamónJ Puerto Rico
Competencias de Programación &VVV;rincipiante
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 152/499
Categoría P#&n"&p&*nt$ CUB P#+@#*''&n@ C+nt$!tP#+5($' !$t
Autor P#+ . Hu*n M*nu$( S+(_ S(+*n M*- 2 6 1
Halidación de Tar e!a" de CrJdi!oT+,*! (*! t*#0$t*! ,$ "# ,&t+ t&$n$n un !&!t$'* ,$ )$#& &"*"&7n ,$ n/'$#+!. E!t+ !$ *"
)$#& &"*# (* *ut$nt&"&,*, ,$( n/'$#+ ,$ (* t*#0$t*. C*,* n/'$#+ t&$n$ un !&@n& &"*,+. L* '*)$"$! (+! p#&'$#+! n/'$#+! *@#up*,+! u$ !u$($n !$# ,$ "u*t#+% !&@n& &"*n $( t&p+ ,$ t*#0$tn/'$#+! !&@n& &"*n (* + &"&n* ,$( #$p#$!$nt*nt$ ,$ !$#)&"&+ - (+! n/'$#+! u$ &,$nt& &"*n */(t&'+! n/'$#+! !$ ut&(&8*n p*#* )$#& &"*# !& $( n/'$#+ ,$ t*#0$t* ,$ "# ,&t+ $! "+##$"t+. A "+n+"$n "+'+ (+!check di#its .
C+n!t#u-* un p#+@#*'* u$ ,*,* (* !&@u&$nt$ 7#'u(* )*(&,$ (+! n/'$#+! ,$ t*#0$t* ,$ "# ,&t+.
1. L+! n/'$#+! p*#$! !$ *"u'u(*n.2. C*,* n/'$#+ &'p*# !$ 'u(t&p(&"* p+# 2 - !$ *"u'u(*.3. L+!check di#its !$ "*("u(*n 5u!"*n,+ $( #$!&,u+ ,$ (+ *"u'u(*,+ ,$ n/'$#+! p*#$! $nt#$ $(
*"u'u(*,+ ,$ n/'$#+! &'p*#$!.
$%emplo deinput (
B!3 B "$ B B$ B!! $
2B$3 ""*$ * *$ <B1! 3<
11$1 ""*$ 1 *$ 1!!! 11
$%emplo de output(
B!3 B "$ B B$ B!! $ VD Q)lido
2B$3 ""*$ * *$ <B1! 3< VD Q)lido
11$1 ""*$ 1 *$ 1!!! 11 VD N(mero de tar8eta erroneo
N+t* Ut&(&8$ *#" &)+! p*#* $( &nput - +utput ""*#,.&n6 ""*#,.+ut%.
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 153/499
C*t$@+#`* PRINCIPIANTE
Aut +# P#+ . Ant+n&+ Ju$#t*!
CUB P#+@#*''&n@ C+nt$!tP#+5($' !$t
M*- 2 6 1
C=$C0$O DE *EC5AS
En 'u" *! *p(&"*"&+n$! $! n$"$!*#&+ ,$t$#'&n$# $" *! *nt$#&+#$! + p+!t$#&+#$! * un* $" * ,* p*#* ,$t$#'&n*# $( )$n"&'&$nt+ ,$ un* t*#0$t* ,$ "# ,&t+%. E!"#&5* un p#+@#*'* u$ #$"&5* u+#'*t+ -- b## bAAAA6 ,+n,$-- $! $( '$!6## $! $( ,`* -AAAA $! $( *9+%6 (* )*(&,$ - ,$t$#'&n$(* $" * ,$( ,`* *nt$#&+# - ,$( p#7 &'+ ,`*. R$"u$#,$ t+'*# $n "+n!&,$#*"&7n u$ n+ t+,+! (+! *9+ 5&!&$!t+! - u$ n+ t+,+! (+! '$!$! t&$n$n (* '&!'* "*nt&,*, ,$ ,`*!.
-es Cantidad de #ías -es Cantidad de #ías1. En$#+ 31 . Hu(&+ 31
2. F$5#$#+ 2 7 2 . A@+!t+ 313. M*#8+ 31 . S$pt&$'5#$ 3<4. A5#&( 3< 1<. O"tu5#$ 31. M*-+ 31 11. N+)&$'5#$ 3<:. Hun&+ 3< 12. D&"&$'5#$ 31
CA0:0 #$ PRU$BA.nput(< b2 b111b3 b1<1b<1b1
<2b2 b1<2b2 b1
:utput(Ant$#&+# * < b2 b1 $! < b2 b1 - p+!t$#&+# $! < b2 b1L* $" * $nt#*,* $! &n"+##$"t*. E( ,`* ,$5$ !$# un n/'$#+ $nt#$ 1 - 3< p*#* $!t$ '$!.Ant$#&+# * <1b<1b1 $! 12b31b1 - p+!t$#&+# $! <1b<2b1Ant$#&+# * <2b2 b1 $! <2b2 b1 - p+!t$#&+# $! <3b<1b1L* $" * $nt#*,* $! &n"+##$"t*. 1 n+ $! *9+ 5&!&$!t+.
%ota UT.!.C$ #$ $NTRA#A $! ARC;./: F$C;A04.N
J&nt L+! *9+! 5&!&$!t+! !+n ,&)&!&5($! $nt#$ 4. E0. 1 2 b 4 X 4
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 154/499
C*t$@+#`* PRINCIPIANTE CUB P#+@#*''&n@ C+nt$!t
Problem setAut +# P#+ . Ant+n&+ Ju$#t*! M*-6 2 6 1
CONHERSION DE N0MEROS 5E-ADECIMA$ES
E( !&!t$'* $ *,$"&'*( $! ut&(&8*,+ "+'+ un* *(t$#n*t&)* *( !&!t$'* 5&n*#&+ 5&n*#&+ p*#* +5t#$p#$!$nt*"&7n ,$ (*! "*nt&,*,$! *('*"$n*,*! $n (* '$'+#&* ,$ un* "+'put*,+#*. E!t$ !&!t$'* p+!$$,&$"&!$`! 1:% ,`@&t+!. S$ pu$,$ $!t*5($"$# (* !&@u&$nt$ "+##$(*"&7n $nt#$ (+! ,`@&t+! $ *"*nt&,*,$! $ p#$!*,*! $n $( !&!t$'* ,$"&'*(.
#igito ;e5adecimal $Guivalente #ecimal #igito ;a5adecimal $Guialente #ecimal1 12 2 A 1<3 3 B 114 4 C 12
D 13: : E 14
F 1
T+,+ n/'$#+ #$p#$!$nt*,+ $n !&!t$'* ,$"&'*( !$ pu$,$ $ p#$!*# "+'+ un* !u'* ,$ p+t$n"&*! ,$ ,&$81<%. P+# $0$'p(+6 $( n/'$#+ 4 2 pu$,$ !$# $ p#$!*,+ "+'+ 4 e 1<2 % e 1<1 % 2 e 1<< %. D&@u*( +#'*6 un n/'$#+ #$p#$!$nt*,+ $n !&!t$'* $ *,$"&'*( pu$,$ !$# $ p#$!*,+ "+'+ (* !u'* ,$ p+t$n"&*! ,$ ,&$"&!$`! 1:%. P+# $0$'p(+6 $( n/'$#+ AD pu$,$ !$# $ p#$!*,+ "+'+ A e 1:2% D1:<% X 1< e 1:2% 13 e 1:1% e 1: <% X2 :< 2< X 2 :
U!t$, ,$!*##+((*#_ un p#+@#*'* u$ !+(&"&t$ un n/'$#+ $ *,$"&'*( "+n un '_ &'+ ,$ +" + % ,`@&
(+ )*(&,$ - u$ ,$t$#'&n$ !u $ u&)*($nt$ ,$"&'*(.Cota! i el n-mero entrado no es válido, se mostratá un mensa e de error * se indicará elprimer dígito inválido.
E/EMP0O
.nput(ADD G41<
FF3:utput(E( $ u&)*($nt$ ,$"&'*( ,$ AD $! 2 :D G4 n+ $! un* #$p#$!$nt*"&7n $ *,$"&'*(. D`@&t+ n+ )_(&,+ GE( $ u&)*($nt$ ,$"&'*( ,$ 1< $! 2:E( $ u&)*($nt$ ,$"&'*( ,$ FF3 $! 4< 3
Nota( UtiliQe de input el archivo de nombre ;$O4.N
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 155/499
C*t$@+#`* P#&n"&p&*nt$ CUB P#+@#*''&n@ C+ P#+5($' !$t
Aut +# P#+ . Hu*n S+(_ S(+*n M*-6 2 6 1
'D 0o7t?are 0olution
Da!e 6indoKing
E( *9+ 2<<< $n"*#* )*#&+! p#+5($'*! $n (*! "+'put*,+#*!. Un+ ,$ $((+! $n $( _#$* p#+@#*'*"&7n ,$ *p(&"*"&+n$!. A(@un*! *p(&"*"&+n$! "#$*,*! $n , "*,*! p*!*,*! ut&#$p#$!$nt*# $( *9+ $n un* $" * (+! /(t&'+! ,+! ,`@&t+! ,$( *9+. P+# $0$'p(+ p*#* $( *9+ $!"#&5$ : . P*#* #$!t*# 1 ,$ 1 !$ #$p#$!$nt*5* *!` > X3. C+'+ !$ +5)&*5*n (+! (+! p#&'$,`@&t+! ,$( *9+6 -* u$ n+ "*'5&*#`*n *!t* $( 2<<<6 'u" +! *#" &)+! n+ @u*#,*n $( *9+ $n p+!&"&+n$!. E!t$ $!t&(+ ,$ p#+@#*'*"&7n +5!+($t* <1> X > "u*n,+ ,$5$#`* !$# 2.
In@ n&$!$ un *(@+#&t'+ ,$ p#+@#*'*"&7n p*#* #$!t*# $" *! $nt#$ !&@(+!. E &!t$ un* t "n&"* u$ pu$,$ ut&(&8*# u$ !$ "+n+"$ "+'+ D*t$ K&un* )$nt*n* )&#tu*( $nt#$ !&@(+! "*,* *9+!. L* '&!'* pu$,$ !$# '+)&,* "*,* < *9+!. P+# $0$'p(+ S& $nt#+ u$ '& )$nt*n* "+'&$n8* $n $( *9+ )$nt*n* "+'&$n8* $n 1 21 - t$#'&n* $n $( *9+ 2<<<. S& $!"#&5+ 1 2< '& )$nt*n* "+'&$n8* $n 1 21 - t$#'&n*#_ $n $( 2<2<. L*! $" *! '*-+#$! ,$( t#*t*n "+'+ !& u$#*n '*-+#$! ,$( 1 2<. E( !&!t$'* !+(+ )$ un* )$nt*n* ,$ $" *!. S& $nt#+ un* $" * '$n+# ,$ 1 21 $( !&!t$'* "#$$#_ u$ $! '$n+# + &*( 2<2<.
.nput(
1B!! *B *1 "! 2" 222! !1 BB1 !! B! 1
:utput(
Qentana : 1B!1 al 2!!!, 1B*BD1B* %1Qentana: 1 "1 al 1B"!, 1B2"D1 %3<Qentana: 2221 al 232!, 23!1D22BB%2Qentana: 1 !1 al 1B!!, 1 B!D1 1%B
Nota( UtiliQe archivos de input y output para este problema 2llamarlos( 'D4 .N y 'D4 :UT6
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 156/499
PRO+RAM $ISTIN+
Una cualidad que parece disminuir con el uso de los lenguajes de programaci6n en ambiente de PC es la
impresion en papel de un "source program" que pueda listar el codigo con enumeraci6n por linea yencabezamiento en cada prigina. Esta opci6n se usa mucho en ambientes de "Mainframe" con listados deprogramas largos que se imprimen con la opci6n "LISTING" para poder examinar detenidamente el programa, susvariables e incluso los mensajes de errores.
La opcion de "LISTING" no solo genera un listado con encabezamiento por pagina y enumeraci6n porlinea, sino que tambien lista los errores de sintaxis si es que existe alguno yen que linea se encuentra. Tambienpuede generar un listado de variables, en donde se definen, en donde se modifican yen donde se utilizan. Esto erade gran ayuda a los programadores de ambiente "Mainframe" y tambien considero que puede ser de ayuda a losprogramadores de ambiente PC.
PROBLEMA
Haga un programa que lea un programa de Pascal de entrada y genere de salida un encabezamiento porpagina y enumere cada linea de codigo que tenga el programa.
PUNTOS IMPORTANTES
Tenga en mente lo siguiente
1. El programa debe imprimir hasta 55 lineas por prigina.
2. En la primera parte del encabezamiento se utilizarfi el nombre del programa puesto despues de PROGRAMcon la extension PAS.
3. En la segunda parte se incluirfi la fecha y hora de la computadora y el dia de la semana.
4. Finalmente en la tercera parte se va enumerando las páginas.
5. Después de enumerar en cada línea, se pone el caracter "colon" ( : )y se deja por lo menos un espacio enblanco.
C*t$@+#`* PRINCIPIANTE CUB P#+@#*''&n@ C+nt$P#+5($' !$t
Aut +# N$((&u, T+##$! M*- 2 6 1
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 157/499
$8$-P!: #$ C:RR.#A
Utilizando de ejemplo el siguiente c6digo:
P5K 56M newton -input, output/T
CKN;'Epsilon % leD*T
Q65Number, root, s root: realT
>E 9N5EPE6'
write9nTwriteCEnter new number -! to uit/: /Tread-number/T
9J number % ! 'LEN >E 9Nritein-number: 12:*, !&!:12:*/T
EN=E ;E 9J number V ! 'LEN >E 9N
rite9n- ... E55K5: number V ! /TEN=E ;E >E 9N
; root :% s rt-number/Twritein-number: 12:*, s root: 12: */TwritelnT
root :% 1T
5EPE6'root :% -numberAroot F root/A2Twritein-root: 2$: *,
1!!.abs-root D s root/As root: 12: 2, ,,/
7N'9 abs-numberAs r-root/ D 1/ V epsilonTEN=
7N'9 number % !
EN=&
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 158/499
S$ ,$5$ @$n$#*# $( !&@u&$nt$ (&!t*,+
neDton.pas at MaF 29G 1999 10#13#25 +age# 1
1: P5K 56M newton -input, output/T 2:
3: CKN;'$: Epsilon % leD*T":*: Q65<: Number, root, s root : realT:B: >E 9N
1!: 5EPE6' 11: writelnT 12: write-^Enter new number -! to uit/: ^/T 13: read-number/T
1$: 1": 9J number %! 'LEN >E 9N 1*: riteln-number:12:*, !&!:12:*/T 1<: EN= 1 : E ;E 9J number V! 'LEN >E 9N 1B: riteln-^...E55K5: number V!_/T 2!: EN= 21: E ;E >E 9N 22: ; root :%s rt-number/T 23: writeln-number:12:*, s root: 12:*/: 2$: writelnT
2": 2*: root :% 1T 2<: 5EPE6' 2 : root :% -numberAroot F root/A2T 2B: writeln-root:2$:*, 3!: 1!!.abs-root ` s root/As root:12:2, 31: ^ _/ 32: 7N'9 abs-numberAs r-root/ ` 1/ VepsilonT 33: EN= 3$: 7N'9 number % ! 3": EN=&
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 159/499
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 160/499
CUTB Programming ContestProblem Set -Expert Division
March 6, 1999
Code +enera!ion
Your employer needs a backend for a translator for a very SIC machine (Simplified InstructionalComputer, apologies to Leiand Beck). Input to the translator will be arithmetic expressions in postfixform and the output will be assembly language code.
The target machine has a single register and the following instructions, where the operand is either anidentifier or a storage location.
LASMDN
STload the operand into the registeradd the operand to the contents of the register subtract the operand from the contents of theregister multiply the contents of the register by the operand divide the contents of the register bythe operand negate the contents of the register store the contents of the register in the operandlocation
An arithmetic operation replaces the contents of the register with the expression result. Temporarystorage locations are allocated by the assembler for an operand of the form OSnO where n is a singledigit.
Input and Output
The input file consists of several legitimate postfix expressions, each on a separate line. Expressionoperands are single letters and operators are the normal arithmetic operators (+, -, *,/) and unary negation
(@). Output must be assembly language code that meets the following requirements:
1. One instruction per line with the instruction mnemonic separated from the operand (if any) by oneblank.
2. One blank line must separate the assembly code for successive expressions.3. The original order of the operands must be preserved in the assembly code.4. Assembly code must be generated for each operator as soon as it is encountered.5. As few temporaries as possible should be used (given the above restrictions).6. For each operator in the expression, the minimum number of instructions must be generated (given
the above restrictions).
A sample input file and corrresponding correct output are on the reverse of this paper.
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 161/499
CUTB Programming ContestProblem Set -Expert Division
March 6, 1999
Sample input Sample output
AB+CD+EF++GH+++ L AA BST $1L CA DST $2L EA FA $2ST $2L GA HA $2A $1
AB+CD+- L AA BST $1L CA DNA $1
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 162/499
CUTB Programamng Contest Problem Set -Expert Division
March 6, 1999
CONHERSION
Convierta de palabra a número dejándose llevar de la siguiente tabla:
primero = 1 undecimo = 11 Vigesimo primero = 21 ducentesimo = 200segundo = 2 duodecimo = 12 trigesimo = 30 tricentesimo = 300
tercero = 3 decimotercero 6decimotercio = 13 trigesimo cuarto = 34 cuadrigentesimo = 400
cuarto = 4 decimocuarto = 14 cuadragesimo = 40 quingentesimo = 500quinto = 5 decimoquinto = 15 quincuagesimo = 50 sexcentesimo = 600sexto = 6 decimosexto = 16 sexagesimo = 60 septingentesimo = 700
septimo = 7 decimoseptimo = 17 septuagesimo = 70 octigentesimo = 800octavo = 8 decimoctavo = 18 octogesimo = 80 nonigentesimo = 900
noveno = 9decimonoveno 6decimonono = 19 nonagesimo = 90 milesimo = 1000
decimo = 10 vigesimo = 20 centesimo = 100
Se tomará 1o siguiente en mente:
1. Se omitirán los acentos en las palabras.2. Las cifras llegan hasta un máximo de cuatro (4) dígitos.3. El programa tiene que detectar errores de sintaxis.
Ejemplo de corrida:
Indique palabra (exit para salir): quincuagesimo segundoquincuagesimo seRundo = 52
Indique palabra (exit para salir): centesimo sexagesimo quintocentesimo sexagesimo quinto = 165
Indique palabra (exit para salir}: milesimo primeromilesimo primero = 1001
Indique palabra (exit para salir}: centesimo nonagesimocentesimo nona2esimo = 190
lndique palabra (exit para salir): septima***error de sintaxis ***
Indique palabra (exit para salir): exit
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 163/499
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 164/499
There will be only simple mathematics equotions like add, subtract, divide and multiply with a maximum ofthree (3) operators. The compare symbols like >, <, >=, <=, <> and = may also be used in the until clause.
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 165/499
CUTB Programming ContestProblem Set -Expert Division
March 6, 1999
You can use the following assembly instructions:
1. JMP - Jump no matter what2. JZ - Jump if the result was Zero3. JNZ - Jump if the result was Not Zero4. JG - Jump if the result was Greater than zero5. JL - Jump if the result was Less than zero6. JGE - Jump if the result was Greater or equal than zero7. JLE - Jump if the result was Less or equal than zero8. DEC - Decrement (subtract one)9. INC - Increment (Add one)10. MOV - Move X,Y (X ("' Y)11. ADD - Add X,Y (X (- X +Y)12. SUB - Subtract X,Y (X (- X -Y)13. MUL- Multiply X,Y (X (- X *Y)14. DIV - Divide X,Y (X (-- X / Y)15. CMP - Compare
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 166/499
Universidad de Puerto RicoBayamónJ Puerto Rico
Competencias de Programación &VV23perto
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 167/499
Fecha M*-+b<3b1 Nombre de la competencia CUTB P#+@#*''&@ C+nt$!tCategoría E p$#t+ Universidad lllllllllllllllllllllllllllllll Autor lllllllllllll Tipo de competencia lllllllllllllllllllllll Problema lllll Algoritmos llllllllllllllllllllllllllllllll
#INAR CA$C0$ATOR0ource File Name( OOOOOOOO4OOO.nput File Name( OOOOOOOO4OOO:utput File Name( OOOOOOOO4OOO
Problem &(
Y+u *#$ t+ #&t$ * p#+@#*' t *t "*n $)*(u*t$ !&'p($ $ p#$!!&+n! u!&n@ 5&n*#- nu'5$#!.T $ $ p#$!!&+n "*n *((+ t $ +((+ &n@ t+?$n!
Binary numbers(Opt&+n*( !&@n6 t $ " *#*"t$#!& *n, K:perators 6>6e6 +# bParenthesis( 2 +#6t+ !p$"& - p#$"$,$n"$ @#+up&n@.
Y+u 'u!t *!!u'$
1. T $ $ p#$!!&+n ! +u(, 5$ $)*(u*t$, #&@ t t+ ($ t $ "$pt $#$ p*#$nt $!&! @#+up&n@2. A(( &nput $ p#$!!&+n! *#$ !-nt*"t&"*((- "+##$"t.3. E*" t+?$n &! !$p*#*t$, 5- +n$ 5(*n? !p*"$.
4. A(( $ p#$!!&+n! &(( 5$ ($!! t *n < " *#*"t$#! &n ($n@t .. A(( +p$#*t&+n! &(( p#+,u"$ &nt$@$# #$!u(t! +n(- &@n+#$ ,$"&'*( p+!&t&+n!%.
K $n *n &nput $ p#$!!&+n &! #$*,6 -+u *#$ t+ p#&nt t *t $ p#$!!&+n *n, &t! "+##$"t )*(u$.:U CAN N:T C:N/$RT FR:- B.NAR T: #$C.-A! T: 0:!/$ T;.0 PR:B!$-4
$5amples(
ENTER E;PRESSIONZ&&K&]^]&&&&&&K&]^] &&&& &&&KK
ENTER E;PRESSIONZ&&K&]_]&&&&&&K&]_]&&&& &&KKKK&&
ENTER E;PRESSIONZ&K&]<]&K&K&]<]&K &K R &
ENTER E;PRESSIONZKM$O.T
Note that ] is eGuivalent to a space4
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 168/499
Fecha M*-+b<3b1 Nombre de la competencia CUTB P#+@#*''&n@ C+nt$!tCategoría E p$#t+ Universidad lllllllllllllllllllllllllllllllllllll Autor lllllllllllll Tipo de competencia llllllllllllllllllllllllllllll Problema lllll Algoritmos llllllllllllllllllllllllllllllllllllll
Direc!or% $i"!ing Command Simula!or 0ource File Name( OOOOOOOO4OOO.nput File Name( OOOOOOOO4OOO:utput File Name( OOOOOOOO4OOO
Problem '(D$)$(+p * p#+@#*' t *t !&'u(*t$! * @$n$#&"#.R "+''*n,. T $ &nput &(( 5$ #$*, #+' *n &nput &($
n*'$, #.R4TOT. T $ " *#*"t$#! *((+ $, &n t *t &($ &(( 5$
1. A ,+t 246t+ !$p*#*t$ t $ &($ n*'$ *n, t $ $ t$n!&+n +pt&+n*(%.2. C *#*"t$#! #+'A t+" Upp$# *n, L+ $#"*!$ &(( 5$ *((+ $,%.3. Nu'5$#! #+' K t+V.
T $ p#+'pt "+''*n, &(( *((+ t $ +((+ &n@ " *#*"t$#!
1. A ,+t 246+pt&+n*(%2. An *!t$#&!?2_6t+ !u5!t&tut$ +n$ +# '+#$ " *#*"t$#!.3. A u$!t&+n '*#?2 6t+ !u5!t&tut$ +n(- +n$ " *#*"t$#.
T $ +((+ &n@ *#$ $ *'p($! + )*(&, "+''*n,!.
DIRe*.E;E6 DIR ABe.COM6 DIR AhBhCh.DAT6 DIR ABChJe.e6 DIR JELP6 DIR e.e6 DIR .hhh6 DIR eAhBe.e
T $ #u($! +# &($ n*'$! &(( 5$ t $ !*'$ u!$, +# MS>DOS. At t $ $n, + t $ p#+@#*' &(( ,&!p(t+t*(! + &($! ,&!p(*-$, +n !"#$$n *n, t $ t+t*( &($! #$*, +n t $ &($. R$'$'5$#6 t $ p#+@#*' "*!$ !$n!&t&)$.0ample output(
C:--AN# ZDIRe.E;EABC.E;EFINISJ.E;EPROGRAM.E;ETEST.E;E
T+t*( &($! #$*, 2 % T+t*( &($! !$($"t$, 4%.C:--AN# ZDIR eJ.eFINISJ.E;EASJ.T;T
T+t*( &($! #$*, 2 % T+t*( &($! !$($"t$, 2%.C:--AN# DIR AhBhCe.e
N+ &($! +un,T+t*( &($! #$*, 2 % T+t*( &($! !$($"t$, <%.
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 169/499
C:--AN# DIR AhCe.eABC.E;EA; TOT.BAT
T+t*( &($! #$*, 2 % T+t*( &($! !$($"t$, 2%.
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 170/499
;roblem 9: <OL ,"C= CON>2C/1?2
S+u#"$ F&($ N*'$ ED3.;;;Input F&($ N*'$ ED3.DATOutput F&($ N*'$ ED3.OUT
#e7ine(
T $ G+(,5*" "+n0$"tu#$ !t*t$! t *t *n- p+!&t&)$ $)$n nu'5$# @#$*t$# t *n 4 "*n 5$ $ p#$!!$,+ t + p#&'$ nu'5$#!. T &! "+n0$"tu#$ *! n$)$# 5$$n "+'p($t$(- p#+)$n6 5ut &t *! 5$$n ,$'+n!t"+'put$# t+ 5$ t#u$ +# * &,$ #*n@$ + $)$n nu'5$#!.
Problem(
G&)$n *n $)$n nu'5$# @#$*t$# t *n 46 &n, t + p#&'$ nu'5$#! &" !u' t+ &t. F+# pu#p+! p#+5($'6 1 &! n+t "+n!&,$#$, * p#&'$ nu'5$#.
.nput(
Input +# t &! p#+5($' "+n!&!t! + * (&!t + $)$n nu'5$#! @#$*t$# t *n 46 +n$ p$# (&n$. T $ n 5$ $ $# t *n 1< ,&@&t! &n ($n@t .
:utput(
E*" (&n$ + t $ p#+@#*' +utput "+n!&!t! + $ *"t(- t #$$ $nt&t&$! t $ +#&@&n*( &nput nu'5 p#&'$! &" !u' t+ t *t nu'5$#.
0ample #ata(
1<
0ample :utput(
O#&@&n*( P#&'$3
1<
$NT$R AN $/$N NU-B$R KfE;ITZ
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 171/499
$OP$RT #./.0.:N
$ON+ $ON+ DIHISION
Problem( +
Y+u *)$ 5$$n *!!&@n$, t+ * t$*' + !+ t *#$> *#, *#$ $n@&n$$#! +#?&n@ +n !up$# "+'put$#! Y+u# t*!? &! t+ #&t$ !+ t *#$ +# &'p($'$nt&n@ 'u(t&p($ ,&@&t ,&)&!&+n6 &" &! t+ ,&)&,$ $ $# ,&@&t! 5- *n- p+!&t&)$ ,&)&!+# ($!! t *n 1<<.
D*t* &n t $ &nput &($! "+'$! &n p*&#!6 &t t $ &#!t (&n$ "+nt*&n&n@ t $ ,&)&,$n, *n, t $ !$"t $ ,&)&!+#. Y+u# p#+@#*' &! t+ *""$pt +n(- "+##$"t ,&)&,$n,! *n, ,&)&!+#!. T u!6 & $&t $# ,&)&!+# "+nt*&n! *n- n+n>,&@&t6 &.$.6 * " *#*"t$# n+t &n Q<.. 6 +# t $ ,&)&!+# &! @#$*t$#$##+# '$!!*@$6 *! ! + n &n t $ !*'p($ +ut ! + n 5$(+ . I -+u #$*, &n t + )*(&, )*(u$!6 -+u *#$ t+ "+'put$ t $ u+t&$nt *n, #$'*&n,$# *n, +utput t $ #$!u(t!
+n t $ !*'p($ +utput ! + n 5$(+ . Y+u *#$ t+ u!$ n+#'*( $n,>+ > &($ '$t +,! t+ t$#'&n*t$ -+u# #$*,! #&nput ,*t* &($. A( *-! !?&p * (&n$6 *! ! + n 5$(+ &n t $ $ *'p($ ,*t*6 5$t $$n t $ ,&)&,$n,b,&)&!+
0ample #ata(
V==
0ample output(
$NT$R F.R0T NU-B$R V$NT$R 0$C:N# NU-B$R =
#ividend is V
#ivisor is =Euotient is =Remainder is K
$NT$R F.R0T NU-B$R =
$NT$R 0$C:N# NU-B$R #ividend is =#ivisor is Euotient is Remainder is +
$NT$R F.R0T NU-B$R KM$O.T CUTB P#+@#*''&n@ C+nt$!t
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 172/499
Universidad de Puerto RicoBayamónJ Puerto Rico
Competencias de Programación &VVIntermedio
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 173/499
CUTB P#+@#*'&n@ CP#+5($' !$M*- 361
.NT$R-$#.AT$ #./.0.:N
DEA$IN+ A DEC O* CARDS
P#+5($' 1
K#&t$ * p#+@#*' t *t6 @&)$n * (&!t + t $ &nt$@$#! 1 t+ 2 &n *n- +#,$# *t!+$)$#6 !&'u(*t$! t $ ,$+ "*#,!. Y+u 'u!t *!!&@n !+'$ "+##$!p+n,$n"$ 5$t $$n t $ nu'5$#! #+' t+ 1 t+ 2 *n, t $ "*#,! &n * !t*n,*#, ,$"2 "*#,!. On$ *- t+ ,+ t &! &! t+ ($t t $ &#!t 13 "*#,! 5$ $*#t!6 t $ n$ t 13 5$ ,&*'+n,!6 t $ n$ t 13 5$ "(u5!6 *(*!t 13 5$ !p*,$!. K&t &n $*" !u&t + 13 "*#,!6 t $ &#!t 1< "*#,! #$p#$!$nt t $ *"$ t #+u@ t $ t$n6 *n, t $ #$t #$$ "*#,! #$p#$!$nt t $ 0*"?6 t $ u$$n6 *n, t $ ?&n@ + t *t !u&t6 #$!p$"t&)$(-.
On t $ 5*!&! + t $ !" $'$ p#$!$nt$, *5+)$6 t $ nu'5$# 1 "+##$!p+n,! t+ t $ *"$ + $*#t!6 t $ nu'5$# 2"+##$!p+n,! t+ t $ t + + $*#t!6 t $ nu'5$# 2: "+##$!p+n, t+ t $ ?&n@ + ,&*'+n,!6 t $ nu'5$# 3 "+##$!p+n,! t+?&n@ + "(u5!6 *n, t $ nu'5$# 2 "+##$!p+n,! t+ t $ ?&n@ + !p*,$!.
Y+u 'u!t! *(!+ ,&!t#&5ut$ t $ ,$*($, "*#,! t+ 4 p(*-$#! 4 p$# p(*-$#% #+' t $ t+p *n, @&)&n@ +n$ "* p(*-$# +n$ *t * t&'$.
:U -U0T U0$ T;$ RA-#:- FUNCT.:N T: 0:!/$ T;.0 PR:B!$-HH
0ample :utput(
MUN#$A!.N91. *"$ + $*#t!2. t + + $*#t!3. t #$$ + $*#t!
4. +u# + $*#t!..2. &n@ + !p*,$!
f #$A!.N91. A"$ + C(u5! 14. N&n$ + D&*'+n,! 2 .F&)$ + J$*#t! 4<. F&)$ + C(u5!2. F+u# + J$*#t! 1 . T$n + Sp*,$! 2 .D$u"$ + D&*'+n,! 41. S& + J$*#t!3.N&n$ + Sp*,$! 1:. &n@ + C(u5! 2 . u$$n + Sp*,$! 42.N&n$ + J$*#t!4. A"$ + J$*#t! 1 . &n@ + Sp*,$! 3<. &n@ + J$*#t! 43.T$n + J$*#t!. E&@ t + D&*'+n,! 1 .S$)$n + C(u5! 31. F+u# + Sp*,$! 44.D$u"$ + C(u5!:. A"$ + D&*'+n,! 1 .S& + C(u5! 32.S& + D&*'+n,! 4 .T #$$ + J$*#t!. H*"? + J$*#t! . . .
. S$)$n + J$*#t! . . .. . . .13. u$$n + C(u5! 2:.D$u"$ + Sp*,$! .3 .H*"? + Sp*,$! 2. F&)$ + D&*'+n,!
P!A $R & P!A $R ' P!A $R = P!A $R +1. A"$ + C(u5! 1.F+u# + J$*#t! 1. N&n$ + Sp*,$! 1. A"$ + J$*#t!2. E&@ t + D&*'+n,! 2. A"$ + D&*'+n,! 2. H*"? + J$*#t! 2. S$)$n + J$*#t!3. . 3. . 3. . 3. .4. u$$n + C(u5! 4. N&n$ + D&*'+n,! 4. T$n + Sp*,$! 4. &n@ + C(u5!
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 174/499
CUTB P#+@#*''&n@ C+P#+5($' !$
M*- 36 1
.NT$R-$#.AT$ #./.0.:N
*RACTIONS TO DECIMA$S
Problem '(
K#&t$ * p#+@#*' t *t &(( *""$pt * #*"t&+n + t $ +#' NbD6 $#$N &! t $ nu'$#*t+# *n,# &! t $ ,$n+'&n*t+#6 t *t p#&+ut t $ ,$"&'*( #$p#$!$nt*t&+n. I t $ ,$"&'*( #$p#$!$nt*t&+n *! * #$p$*t&n@ !$ u$n"$ + ,&@&t!6 &t ! +u(, 5$ &n,&&n 5#*"?$t!. F+# $ *'p($6 1b3 X.33333333 &! ,$n+t$, *! . 3%<6 *n, 41b333 .123123123 &! ,$n+t$, *!. 123%.
T-p&"*( "+n)$#!&+n! *#$
1b3 X . 3%22b X 4.41b X . 142 %3b X .34 b : X . <3 142 %
T$!t -+u# p#+@#*' &t t $ #*"t&+n! *5+)$ *n, t $ #*"t&+n 11b .
S*'p($ Run
$NT$R N &$NT$R #
1b X. 142 %
$NT$R N KM$O.T
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 175/499
CUTB P#+@#*''&n@ C+P#+5($' !$
M*- 36 1
.NT$R-$#.AT$ #./.0.:N
EI+5T L0EEN 6IT5 A T6IST
Problem =(
E&@ t u$$n! "*n 5$ *##*n@$, +n * " $!! 5+*#, !+ t *t n+ u$$n &! un,$# *tt*"? #+' *n- + t $&n +t $# +#,!6 !+ t *t n+ #+ +# "+(u'n +# ,&*@+n*( "+nt*&n! '+#$ t *n +n$ u$$n. K#&t$ * p#+@ p(*"$ t $ p+!&t&+n + u$$n! +n * " $!! 5+*#, *n, $n!u#$! t *t n+ u$$n! *#$ un,$# *tt*"?. Y+u# p#! +u(, &#!t ,#* t $ " $!! 5+*#, ,&!p(*-&n@ t $O '*t#& &t d! #$p#$!$nt&n@ t $ u$$n p+!&t&+n. T p#+@#*' 'u!t *(!+ !$*#" *n, ,&!p(*- *(( t $ !+(ut&+n! +# t &! p#+5($'. T $ *n! $#! ! +u(, ! + t $ "+#!+(ut&+n.
Note( N+ *#,> &#$, !+(ut&+n *#$ *((+ $,W.
0ample :utput(
& ' = + , L
& E
' E
= E
+ E
E
, E
E
L E
PR$00 $NT$R F:R N$OT 0:!UT.:N
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 176/499
.NT$R-$#.AT$ #./.0.:N
P077$E
Problem +(
Y+u *#$ t+ #&t$ * p#+@#*' &" &(( !"*n * 1< 1< " *#*"t$# @#&,6 *n, &n, t $ +""u##$n" p*#t&"u(*# +#, &n t $ @#&,. T $ +#, "*n 5$ +un, +#&8+nt*((-6 )$#t&"*((-6 ,&*@+n*((-:N AN#.R$CT.:N . T $ &nput &($n*'$ &(( 5$ PU LE.DAT.
F+# &n!t*n"$6 @&)$n * @#&, 4 4%
A B D ;O J P
J K U PP L U P
0ample :utput(
$NT$R @:R# 2+ characters long6Z BOKLBOKL &! &n p+!&t&+n!6 261%6 262%6 263%6 26 4%.
$NT$R @:R#2+ characters long6 PULPPULP &! &n p+!&t&+n!6 44%6 34%6 26 4%6 164%.
$NT$R @:R# 2+ characters long6 PULLT $ +#, PULL &! n+t &n t $ @#&,.
$NT$R @:R# 2+ characters long6 <fE;ITZ
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 177/499
Universidad de Puerto RicoBayamónJ Puerto Rico
Competencias de Programación &VV;rincipiantes
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 178/499
CUTB Programming ContestProblem setMay 3, 1997
BEGINNERS DIVISION
E-PONENTIATION
Problem 1:
Write a program that implemems exponentiation. The following rules must be observed.
1. For the following expression: N e, where N and e are integers.When e > 0, N e = (N * .... N) e timesWhene=0, N e =1
When e < 0, N e = 1/(N * ....... N) e times
2. DO NOT USE ANY MATHEMATICAL BUILT-IN FUNCTION to solve thisproblem, other than +, -, * and/.
Sample Data:
ENTER NUMBER>5ENTER EXPONENT>3
Sample Output:
RESULT = 125
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 179/499
CUTB Programming ContestProblem setMay 3, 1997
BEGINNERS DIVISION
DEA$IN+ A DEC O* CARDS
Problem 2:
Write a program that e-iven a list of the integers 1 to 52 in any order whatsoever, simulates the dealingof a d, of cards. You must assign some correspondence between the numbers from 1 to 52 and the cards in astandard deck of 52 cards. One way to do this is to let the first 13 cards be hearts, the next 13 be diamonds, then,-xt 13 be clubs, and the last 13 be spades. Within each suit of 13 cards, the first 10 cards represent the acethrough the ten, and the remaining three cards represent the jack, the queen, and the king of that suit,respectively.
On the basis of the scheme presented above, the number 1 corresponds to the ace of hearts, the number 2corresponds to the two of hearts, the number l0 corresponds to the ten of hearts, the number 13 correspond tothe king of hearts, the number 26 correspond to the king of diamonds, the number 39 corresponds to the king ofclubs, and the number 52 corresponds to the king of spades.
YOU MUST USE THE RANDOM FUNCTION TO SOLVE THIS PROBLEM!!
Sample Output:
<UNDEALING>1. ace of hearts2. two of hearts3. three of hearts4. four of hearts...52. King of spades
<DEALING>1. Ace of Clubs2. Four of Hearts3. Nine of Spades4. Ace of Hearts5. Eight of Diamonds6. Ace of Diamonds...52. Queen of Clubs
PRESS ENTER TO EXIT>
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 180/499
CUTB Programming ContestProblem set
May 3, 1997
BEGINNERS DIVISION
S0#TRACTIN+ #I+ N0M#ERS
Problem 3:
Write a program that subtract two numbers up to 32 characters long. Both numbers must be included inthe same line and they will be separated by a blank space. Also assume both numbers are integers and positives.
Example Output:
ENTER NUMBERS> 400 321400 - 321 = 79
ENTER NUMBERS> 1000 20011000- 2001 =-1001
ENTER NUMBERS> 0 <EXIT>
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 181/499
CUTB Programming ContestProblem set May 3, 1997
BEGINNERS DIVISION
*ACE O* T5E C$OC
Problem 4:
Write a program that inputs a time such as 11:35 (35 minutes after the hour 11), and then draws the faceof a clock with the hour and minute hands positioned to indicate the time. The program needs to validate inputtime. You have free format to design the clock (in CHARACTER environment only), but the time must belegible to the user. You can use the full screen to display time if you want.
Example Output:
ENTER TIME> 11:35
/ 11 12 1 \ / * \
/ 10 * 2 \ / * \ 9 3
\ , / \8 * 4/ \ * / \ 7 * 5 / \ 6 /
PRESS ENTER TO EXIT>
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 182/499
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 183/499
Universidad de Puerto RicoBayamónJ Puerto Rico
Competencias de Programación &VV,23perto
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 184/499
CUTB Programming ContestProblem Set
April 27, 1996
EXPERT DIVISION
CA#RA COMPI$ERoblem 3:
Input File Name:Output File Name:CABRA. SRC CABRA. OUT
Definition:A string is any combination of blank, letters, digits and special characters. Words are groups of
characters separated by blanks.
Problem:Develop a CABRA language parser/compiler. The CABRA (Compiler And Basic Reference
Assembler) language has the following features:
1. Can handle up to 20 variables, all of which are global.2. Variables can be up to 6 characters long.3. Only strings (up to 40) can be assigned to variables.4. A variable can store strings up to 40 characters.
A CABRA programmer can use:
1. A COUNT function, which will count, the amount of characters whitin a string(one argument).
2. A PRINT function, which will print, the value for a variable (one argument).3. A BEGIN symbol, which is used to mark the beginning of a program.4. An END symbol, which is used to mark the end of a program.5. An assignment symbol (=), which is used to assign strings to variables.
All functions are reserved symbols. The CABRA compiler should print, an error if.'
1. Any function name is used as a symbol.2. Any unassigned symbol is used in a function.
3. Any undefined function is used.4. Any syntax error. (DO NOT DESCRIBE THE I~RROR!!!)
Additional information:
1. No nested functions are allowed.2. No need to check for case sensitivity.3. THE COMPILER MUST READ UP TO 5 PROGRAMS AS DATA.
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 185/499
A sample CABRA program is:
BEGINA1 = "VACA";A2 = "CABALLO";A3 = "GALLINA";C1 = COUNT (A1)',
C2 = COUNT (A2);C3 = COUNT (A3)PRINT (A1);PRINT (C1);PRINT (A2);PRINT (C2);PRINT (A3);PRINT (C3);END
BEGINNING
CABRA- "YES";PRINT (CABRA),END
And its output will be:
Program # 1:VACA4CABALLO7
GALLINA7
Program #2:Syntax Error at Line 1
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 186/499
Universidad de Puerto RicoBayamónJ Puerto Rico
Competencias de Programación &VV,;rincipiantes
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 187/499
Fecha Ap#&( 2 1 : Nombre de la competencia P#+@#*''&n@ C+nt$!tCategoría B$@$nn$#! D&)$!&+n Universidad U P R BAutor Tipo de competenciaProblema <1 Algoritmos
MORSE CODE
0ource File Name( -:R0$4 .N
.nput File Name( -:R0$4 C:#
-:R0$4 #$C Definition:
Perhaps the most famous of all coding schemes is the Morse code, developed by Samuel Morse in 1873for use with the telegraph system. The Morse code assigns a series of dots and dashes to each letter ofthe alphabet, each digit, and a few special characters (such as the period, comma, colon and semicolon).In sound-oriented systems, the dot represents a short sound and the dash represents a long sound. Otherrepresentations of dots and dashes are used with light-oriented systems and signal flag systems.
Separation between words is indicated by a space, or, quite simply, the absence of a dot or dash. In a sound-oriented system,
a space is indicated by a short period of time during which no sound is transmitted. The international version of' the Morse
code is the following table:
-:R0$ C:#$
A ,) ( ,))) S ,,,# ),,, ),) T )C ),), $ ,),, 0 ,,)D ),, M )) H ,,,)E , N ), 6 ,))* ,,), O ))) - ),,)
+ )), P ,)), ),))5 ,,, L )),) 7 )),,I .. R .-.
Problem:
Write a program that reads several lines of text ( MORSE.IN ) and then create a new one using theMorse code ( MORSE.COD ). Read the new file and decodeit to text again ( MORSE.DEC ). Assume4 characters of Morse code per character.
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 188/499
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 189/499
S*'p($ D*t*
0$!$CT$# C:!:R0 R#J @J :RJ BN
ENTER COLORS &Z R#J BUJ BNJ @ MATCJ BDJ @;J @;J N:
ENTER COLORS ' Z R#J :RJ BNJ @ MATCJ BDJ @;J @;J @;
ENTER COLORS =Z R#J @J BNJ :RMATCJ BDJ BDJ @;J @;
ENTER COLORS +Z R#J @J :RJ BN MATCJ BDJ BDJ BDJ BD
YOU KIN WWWWW
SECOND GAME%
0$!$CT$# C:!:R0 R#J @J R#J @ENTER COLORS &Z R#J BUJ BNJ @ MATCJ BDJ BDJ N:J N:
ENTER COLORS ' Z @J BUJ BNJ R# MATCJ @;J @;J N:J N:
ENTER COLORS =Z R#J BUJ BNJ @ MATCJ BDJ BDJ N:J N:
ENTER COLORS +Z R#J :RJ :RJ @
MATCJ BDJ BDJ N:J N:ENTER COLORS Z R#J 9NJ 9NJ @ MATCJ BDJ BDJ N:J N:
ENTER COLORS , Z R#J R#J R#J @ MATCJ BDJ BDJ BDJ N:YOU LOSEWWWWW
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 190/499
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 191/499
Fecha Ap#&( 2 1 : Nombre de la competencia P#+@#*''&n@ C+nt$!tCategoría BEGINNERS DIVISION Universidad U.P.R.B.Autor Tipo de competenciaProblema <3 Algoritmos
MEAS0REMENT AND 0NIT CONHERSION
Problem:
Write a MENU-DRIVEN program that allows the user the following options:
1) Convert measurements from minutes to hours (two decimal places).2% Convert feet to meters ( 1 foot = 0.3048 meter, two decimal places)3% Convert from degrees Fahrenheit to degrees Celsius ( F = 1.8 C + 32).4) Exit Program.
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 192/499
UNIVERSIDAD DE PUERTO RICO
RECINTO DE MAYA UE1
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 193/499
University of Puerto RicoMayaguez Campus
ICO- C*allen%e Expert Division
Sponsored by
AEICand Lucent Technologies
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 194/499
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 195/499
Fecha l<4lb<3b2<<< Nombre de la competencia l ICOM ChallengeCategoría llE p$#t+ l Universidad Un&)$#!&,*, ,$ Pu$#t+ R&"+6 M*-*@u$8Autor lllllllllllll Tipo de competencia llllllllllllllllllllllllllllll Problema lllll Algoritmos llllllllllllllllllllllllllllllllllllll
Input File : huffman.in
Output File : huffman.outS+u#"$ F&($u '*n.
Hariable Radi9 5uffman Encoding
Problem Description
Huffman encoding is a method of developing an optimal encoding of the symbols in asource alphabet using symbols from a target alphabet when the frequencies of each of the
symbols in the source alphabet are known. Optimal means the average length of anencoded message will be minimized. In this problem you are to determine an encoding ofthe first N uppercase letters (the source alphabet, S 1 through S N, with frequencies f 1 through
f n) into the first R decimal digits (the target alphabet, T 1 through T R).
Consider determining the encoding when R=2. Encoding proceeds in several passes. Ineach pass the two source symbols with the lowest frequencies, say S 1 and S 2, are groupedto form a new "combination letter" whose frequency is the sum of f 1 and f 2. If there is a tiefor the lowest or second lowest frequency, the letter occurring earlier in the alphabet isselected. After some number of passes only two letters remain to be combined. The letterscombined in each pass are assigned one of the symbols from the target alphabet.
The letter with the lower frequency is assigned the code 0, and the other letter is assignedthe code 1. (If each letter in a combined group has the same frequency, then 0 is assignedto the one earliest in the alphabet. For the purpose of comparisons, the value of a"combination letter" is the value of the earliest letter in the combination.) The final codesequence for a source symbol is formed by concatenating the target alphabet symbolsassigned as each combination letter using the source symbol is formed.
The target symbols are concatenated in the reverse order that they are assigned so that thefirst symbol in the final code sequence is the last target symbol assigned to a combinationletter.
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 196/499
The two illustrations below demonstrate the process for R-2.
Symbol Frequency Symbol FrequencyA 5 A 7B 7 B 7C ' 8 C 7D 15 D 7
Pass 1: A and B grouped Pass 1: A and B groupedPass 2: {A.B} and C grouped Pass 2: C and D grouped
Pass 3: {A,B,C} and D grouped Pass 3: {A,B} and {C,D} groupedResulting codes: A=110, B=1 l 1, C=10, D=10 Resulting codes: A=00, B=01, C=10, D=11
Avg. Length=(3*5+3*7+2*8+l*15)/35-1.91 Avg. Length=(2*7+2*7+2*7+2*7)/28=2.00
When R is larger than 2, R symbols are grouped in each pass. Since each pass effectivelyreplaces R letters or combination letters by 1 combination letter, and the last pass mustcombine R letters or combination letters, the source alphabet must contain k*(R-1)+Rletters, for some integer k .
Since N may not be this large, an appropriate number of fictitious letters with zerofrequencies must be included. These fictitious letters are not to be included in the output.
In making comparisons, the fictitious letters are later than any of the letters in the alphabet.
Now the basic process of determining the Huffman encoding is the same as for the R= 2case. In each pass, the R letters with the lowest frequencies are grouped, forming a newcombination letter with a frequency equal to the sum of the letters included in the group.The letters that were grouped are assigned the target alphabet symbols 0 through R-1. 0 isassigned to the letter in the combination with the lowest frequency, 1 to the next lowestfrequency, and so forth. If several of the letters in the group have the same frequency, theone earliest in the alphabet is assigned the smaller target symbol, and so forth.
The illustration below demonstrates the process for R=.3.
Symbol FrequencyA 5B 7C 8D 15
Pass 1: ? (fictitious symbol), A and B are groupedPass 2: {?,A,B ), C and D are grouped
Resulting codes: A=I I, B=12, C=0, D=2Avg. Length=(2*5+2*7+ 1*8+ 1*15)/35=1.34
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 197/499
Input
The input will contain one or more data sets, one per line. Each data set consists of aninteger value for R (between 2 and 10), an integer value for N (between 2 and 26), and theinteger frequencies f 1 through f N, each of which is between 1 and 999.
The end of data for the entire input is the number 0 for R; it is not considered to be aseparate data set.
For each data set, display its number (numbering is sequential starting with 1) and theaverage target symbol length (rounded to two decimal places) on one line. Then display the
N letters of the source alphabet and the corresponding Huffman codes, one letter and codeper line. The examples below illustrate the required output format.
Sample Input
2 5 5 10 20 25 402 5 4 2 2 1 13 7 20 5 8 5 12 6 9
4 6 10 23 18 25 9 120
Sample Output
Set 1; average length 2.10A: 1100B: 1101C: 111D: 10E: 0
Set 2; average length 2.20A: 11B: 00C: 01D: 100E: 101
Set 3; average length 1.69A: 1B: 00C: 20D: 01E: 22F: 02G: 21
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 198/499
Set 4; average length 1.32A: 32B: 1C: 0D: 2E: 31F: 33
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 199/499
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 200/499
F+# t +!$ un *'&(&*# &t P*!"*( !-nt* 6 t $ $ *'p($ *t t $ $n, + t &! p#+5($' "+'p($t$(- ,$ &n$! t $ !'*(( !u5!$t +! P*!"*( n$$,$,.
.nput
T $ &nput &! t $ !&n@($ &nt$@$#n +n * (&n$ 5- &t!$( &t 1 ≤ n ≤ :.
:utput
T $ +utpu &! * "+'p*t&5($ !t*n,*#, P*!"*( p#+@#*' '$$t&n@ t $ "#&t$#&* !p$"& &$, *5+)$.
0ample .nput
3
0ample :utput
pro ram sort -input,output /Tvara,b,c : inte erTbe in
readln -a,b,c/Tif a V b t4en
if b V c t4enwriteln -a,b,c/
else if a V c t4enwriteln -a,c,b/
elsewriteln -c,a,b/
elseif a V c t4en
wirteln -b,a,c/else if b V c t4en
writeln -b,c,a/else
writeln -c,b,a/end&
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 201/499
(nput F&($ u*,t#$$!.&nOutput F&($ u*,t#$$!.+utS+u#"$ F&($ u*,t#$$!.
Luad!ree"
Problem #escription A u*,t#$$ &! * #$p#$!$nt*t&+n +#'*t u!$, t+ $n"+,$ &'*@$!. T $ un,*'$nt*( &,$* 5$ &n, t&! t *t *n- &'*@$ "*n 5$ !p(&t &nt+ +u# u*,#*nt!. E*" u*,#*nt '*- *@*&n 5$ !p(&u*,#*nt!6 $t". In t $ u*,t#$$6 t $ &'*@$ &! #$p#$!$nt$, 5- * p*#$nt n+,$6 &($ t $ +u# u*,#*n#$p#$!$nt$, 5- +u# " &(, n+,$!6 &n * p#$,$t$#'&n$, +#,$#.
O "+u#!$6 & t $ +($ &'*@$ &! * !&n@($ "+(+#6 &t "*n 5$ #$p#$!$nt$, 5- * u*,t#$$ "+n!
n+,$. In @$n$#*(6 * u*,#*nt n$$,! +n(- t+ 5$ !u5,&)&,$, & &t "+n!&!t! + p& $(! + ,& $##$!u(t6 t $ u*,t#$$ n$$, n+t 5$ + un& +#' ,$pt .
A '+,$#n "+'put$# *#t&!t +#?! &t 5(*"?>*n,> &t$ &'*@$! + 32 32 un&t!6 +# * t+t*( + 1<24 p$# &'*@$. On$ + t $ +p$#*t&+n! $ p$# +#'! &! *,,&n@ t + &'*@$! t+@$t $#6 t+ +#' * n$#$!u(t&n@ &'*@$ * p& $( &! 5(*"? & &t *! 5(*"? &n *t ($*!t +n$ + t $ "+'p+n$t &'*@$&t$.
T &! p*#t&"u(*# *#t&!t 5$(&$)$! &n *t $ "*((! t $ preferred fullness +# *n &'*@$ t+ 5$ &nt$#$!t&t+ !$(( +# 5&@ 5u"?!% t $ #n+!t &'p+#t*nt p#+p$#t- &! t $ nu'5$# + &(($, 5(*"?% p& $(! 5$ +#$ *,,&n@ t + &'*@$! t+@$t $#6 $ +u(, (&?$ t+ ?n+ + '*n- p& $(! &(( 5$ 5(*"? &n
#$!u(t&n@ &'*@$. Y+u# 0+5 &! t+ #&t$ * p#+@#*' t *t6 @&)$n t $ u*,t#$$ #$p#$!$nt*"*("u(*t$! t $ nu'5$# + p& $(! t *t *#$ 5(*"? &n t $ &'*@$6 &" &! t $ #$!tu(t + *,,&n@ t $t+@$t $#.
In t $ &@u#$6 t $ &#!t $ *'p($ &! ! + n #+' t+p t+ 5+tt+'% *! &'*@$6 u*,t#$$6 p#$+#,$# !t,$ &n$, 5$(+ % *n, nu'5$# + p& $(!. T $ u*,#*nt nu'5$#&n@ &! ! + n *t t $ t+p + t $ &@u#
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 202/499
2 13 4
X
X
pp$$$ p $$ $ p$ $p$$ $ X pp$$$ p$$ $
44 32< X :4<
.nput
T $ &#!t (&n$ + &nput !p$"& &$! t $ nu'5$# + t$!t "*!$! % % -+u# p#+@#*' *! t+ p#+"$!!. T $ &n$*" t$!t "*!$ &! t + !t#&n@!6 $*" !t#&n@ +n &t! + n (&n$. T $ !t#&n@ &! t $ p#$>+#,$#u*,t#$$6 &n &" t $ ($tt$# dpd &n,&"*t$! * p*#$nt n+,$6 t $ ($tt$# d d u((% * 5(*"? u*,#*d$d $'t-% * &t$ u*,#*nt. It &! @u*#*nt$$, t *t $*" !t#&n@ #$p#$!$nt! * )*(&, u*,t#$$6 + t $ t#$$ &! n+t '+#$ t *n 5$"*u!$ $*" p& $( *! +n(- +n$ "+(+#%.
:utputF+# $*" t$!t "*!$6 p#&nt +n +n$ (&n$ t $ t$ t T $#$ *#$ 5 5(*"? p& $(!.d6 $#$ 5 &! t $ nu'5$# + 5(* p& $(! &n t $ #$!u(t&n@ &'*@$.
0ample .nput
3ppeeefpffeefepefepeefepeeef
peefepeeefpeepefefe
0ample .nput
'4ere are *$! blac pixels&
'4ere are "12 blac pixels&
'4ere are 3 $ blac pixels .
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 203/499
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 204/499
University of Puerto RicoMayaguez Campus
!"#$ "%allen&e ' Intermediate Division
Sponsored by
AEICand Lucent Technologies
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 205/499
Table of Contents
Problem Page
1. Packets .......................................................................................................................3
2. Telephone Tangles .....................................................................................................4
3. Variable Radix Huffman Encoding ............................................................................6
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 206/499
ICOM Challenge Programming ContestMarch 4, 2000
Intermediate Division
Input File: packets.inOutput File: packets.outSource File: packets.xxx
Packe!"
Problem Description
A factory produces products packed in square packets of the same height h and of the sizes 1x1, 2x2,3x3, 4x4, 5x5, 6x6. These products are always delivered to customers in the square parcels of the sameheight h as the products have and of the size 6x6. Because of the expenses it is the interest of thefactory as well as of the customer to minimize the number of parcels necessary to deliver the orderedproducts from the factory to the customer. A good program solving the problem of finding the minimal
number of parcels necessary to deliver the given products according to an order would save a lot ofmoney. You are asked to make such a program.
Input
T $ &nput &($ "+n!&!t! + !$)$#*( (&n$! !p$"& -&n@ +#,$#!. E*" (&n$ !p$"& &$! +n$ +#,$#. O#,$#! *#$ ,$!"#&5
!$p*#*t$, 5- +n$ !p*"$ #$p#$!$nt&n@ !u""$!!&)$(- t $ nu'5$# + p*"?$t! + &n,&)&,u*( !&8$ #+' t $ !'*(($!t !&8$ 1
5&@@$!t !&8$ : :. T $ $n, + t $ &nput &($ &! &n,&"*t$, 5- t $ (&n$ "+nt*&n&n@ !& 8$#+!.
Output
The output file contains one line for each line in the input file. This line contains the minimal numberof parcels into which the order from the corresponding line of the input file can be packed. There is noline in the output file corresponding to the last "null" line of the input file.
Sample Input
! ! $ ! ! 1< " 1 ! ! !
! ! ! ! ! !
Sample Output21
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 207/499
ICOM Challenge Programming ContestMarch 4, 2000
Intermediate Division
Input File: tangle.inOutput File: tangle.outSource File: tangle.xxx
Telep one Tangle"
Problem Description
A large company wishes to monitor the cost of phone calls made by its personnel. To achieve this thePABX (Private Automatic Branch Exchange) logs, for each call, the number called (a string of up to15 digits) and the duration in minutes. Write a program to process this data and produce a reportspecifying each call and its cost, based on standard Telecom charges.
International (IDD) numbers start with two zeroes (00) followed by a country code (1-3 digits)followed by a subscriber's number (4-10 digits). National (STD) calls start with one zero (0) followedby an area code (1-5 digits) followed by the subscriber's number (4-7 digits). The price of a call isdetermined by its destination and its duration. Local calls start with any digit other than 0 and are free.
Input
Input will be in two parts. The first part will be a table of IDD and STD codes, localities and prices asfollows:
Code Locality nameSprice in cents per minute
where represents a space. Locality names are 25 characters or less. This section is terminated by aline containing 6 zeroes (000000).
The second part contains the log and will consist of a series of lines, one for each call, containing thenumber dialled and the duration. The file will be terminated a line containing a single #. The numberswill not necessarily be tabulated, although there will be at least one space between them. Telephonenumbers will not be ambiguous.
Output
Output will consist of the called number, the country or area called, the subscriber's number, theduration, the cost per minute and the total cost of the call, as shown below.
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 208/499
Local calls are costed at zero. 6f the number has an invalid code, list the area as DUnEnoFnDand the cost as G'.00.
Sample Input
! B2" >roadwood 1!3 6rrowtown 3!!*1 6ustralia 1$!!!!!!!!31"2* 22!!*1 "32<B 3! B2"*2 <213 122<<B<*! 1!!2 32<*B "?
Sample Output
!31"2* 6rrowtown 1"2* 22 !&3 &3*!!*1 "32<B 6ustralia "32<B 3 1&$! $&2!! B2"*2 <213 >roadwood *2 <213 122 !& 1 B & 2<<B<*! ocal <<B*<! 1 !&!! !&!!!!2 32<*B 7n nown " D1&!!
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 209/499
ICOM Challenge ProgrammingContest March 4, 2000Intermediate Division
Input File: huffman.inOutput File: huffman.out
Source File: huffman.xxx
Hariable Radi9 5uffman Encoding
Problem Description
Huffman encoding is a method of developing an optimal encoding of the symbols in a source alphabet usingsymbols from a target alphabet when the frequencies of each of the symbols in the source alphabet are known.Optimal means the average length of an encoded message will be minimized. In this problem you are todetermine an encoding of the first N uppercase letters (the source alphabet, S 1 through S N , with frequencies f 1
through f n) into the first R decimal digits (the target alphabet, T 1 through T R).Consider determining the encoding when R=2. Encoding proceeds in several passes. In each pass the two sourcesymbols with the lowest frequencies, say S 1 and S 2, are grouped to form a new "combination letter" whosefrequency is the sum of f 1 and f 2. If there is a tie for the lowest or second lowest frequency, the letter occurringearlier in the alphabet is selected. After some number of passes only two letters remain to be combined. Theletters combined in each pass are assigned one of the symbols from the target alphabet.
The letter with the lower frequency is assigned the code 0, and the other letter is assigned the code 1. (If eachletter in a combined group has the same frequency, then 0 is assigned to the one earliest in the alphabet. For thepurpose of comparisons, the value of a "combination letter" is the value of the earliest letter in the combination.)
The final code sequence for a source symbol is formed by concatenating the target alphabet symbols assigned aseach combination letter using the source symbol is formed.
The target symbols are concatenated in the reverse order that they are assigned so that the first symbol in thefinal code sequence is the last target symbol assigned to a combination letter.
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 210/499
The two illustrations below demonstrate the process for R=2 .
Symbol FrequencyA 5B 7C 8D 15
Pass 1: A and B grouped
Pass 2: (A,B) and C groupedPass 3: (A,B,C) and D groupedResulting codes: A=110, B=111, C=10, D=10Avg. Length=(3*5+3*7+2*8+ 1*15)/35=1.91
Symbol FrequencyA 7B 7C 7D 7
Pass 1: A and B grouped
Pass 2: C and D groupedPass 3: {A,B} and {C,D} groupedResulting codes: A=00, B=01, C=10, D=11Avg. Length=(2*7+2*7+2*7+2*7)/28=2.00
When R is larger than 2, R symbols are grouped in each pass. Since each pass effectively replaces R letters orcombination letters by 1 combination letter, and the last pass must combine R letters or combination letters, thesource alphabet must contain k*(R-1)+R letters, for some integer k.
Since N may not be this large, an appropriate number of fictitious letters with zero frequencies must beincluded. These fictitious letters are not to be included in the output. In making comparisons, the fictitious
letters are later than any of the letters in the alphabet.
Now the basic process of determining the Huffman encoding is the same as for the R=2 case. In each pass, the R letters with the lowest frequencies are grouped, forming a new combination letter with a frequency equal tothe sum of the letters included in the group. The letters that were grouped are assigned the target alphabetsymbols 0 through R-1.0 is assigned to the letter in the combination with the lowest frequency, 1 to the nextlowest frequency, and so forth. If several of the letters in the group have the same frequency, the one earliest inthe alphabet is assigned the smaller target symbol, and so forth.
The illustration below demonstrates the process for R=3.
Symbol FrequencyA 5B 7C 8D 15
Pass 1: ? (fictitious symbol), A and B are groupedPass 2: (?,A,B}, C and D are groupedResulting codes: A=1 1, B=12, C=0, D=2Avg. Length=(2*5+2*7+ 1 *8+1 *15)/35=1.34
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 211/499
Input
The input will contain one or more data sets, one per line. Each data set consists of an integer value for R(between 2 and 10), an integer value for N (between 2 and 26), and the integer frequencies f 1 through f N, each ofwhich is between 1 and 999.
The end of data for the entire input is the number 0 for R; it is not considered to be a separate data set.
Output
For each data set, display its number (numbering is sequential starting with 1) and the average target symbollength (rounded to two decimal places) on one line. Then display the N letters of the source alphabet and thecorresponding Huffman codes, one letter and code per line. The examples below illustrate the required outputformat.
Sample Input
2 5 5 10 20 25 402 5 4 2 2 1 13 7 20 5 8 5 12 6 94 6 10 23 18 25 9 120
Sample Output
Set 1; average lengthA: 1100B: 1101C: 111D: 10
E: 0
2.10
Set 2; average lengthA: 11B: 00C: 01D: 100E: 101
2.20
Set 3; average length 1.69A: 1B: 00C: 20D: 01E: 22F: 02G: 21
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 212/499
Set 4; average length 1.32A: 32B: 1C: 0D: 2E: 31F: 33
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 213/499
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 214/499
Table of Contents
Problem Page
1. MasterMind Hints ......................................................................................................3
2. Recognizing Good ISBNs ..........................................................................................6
3. Packets........................................................................................................................8
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 215/499
ICOM Challenge Programming ContestMarch 4, 2000
Beginner Division
Input File: master, inOutput File: master.outSource File: master.xxx
Ma"!er)Mind 5in!"
Problem Description
MasterMind is a game for two players. One of them, Designer, selects a secret code. The other, Breaker, triesto break it. A code is no more than a row of colored dots. At the beginning of a game, the players agree uponthe length N that a code must have and upon the colors that may occur in a code.
In order to break the code, Breaker makes a number of guesses, each guess itself being a code. After each
guess Designer gives a hint, stating to what extent the guess matches his secret code.In t &! p#+5($' -+u &(( 5$ @&)$n * !$"#$t "+,$ !1 sn *n, * @u$!! # 1 # n6 *n, *#$ t+ ,$t$#'&n$ t $ &nt. A &consists of a pair of numbers determined as follows.
A match is a pair (i,j), 1 < i < n and 1 < j< n, such that si = g j. Match (i,j) is called strong when i = j, and iscalled weak otherwise. Two matches (i,j) and (p,q) are called independent when i = p if and only if j = q. A setof matches is called independent when all of its members are pairwise independent. The following table is anexample of how a match pair is given by the Designer of the secret code to the Breaker.
Brea3er9uessNumber
Breaker GuessCode
Match Pair ( i,j)
1 1123 (1,1)2 4335 (2,0)3 6551 (1,2)4 6135 (1,2)5 1355 (4,0)
D$!&@n$# " ++!$! *n &n,$p$n,$nt !$t M + '*t" $! +# &" t $ t+t*( nu'5$# + '*t" $! *n, t $ nu'5$!t#+n@ '*t" $! *#$ 5+t '* &'*(. T $ &nt t $n "+n!&!t! + t $ nu'5$# + !t#+n@ +((+ $, 5- t $ nu'5$$*? '*t" $! &n . N+t$ t *t t $!$ nu'5$#! *#$ un& u$(- ,$t$#'&n$, 5- t $ !$"#$t "+,$ *n, t $ @u$!!.&nt tu#n! +ut t+ 5$ n6<%6 t $n t $ @u$!! &! &,$nt&"*( t+ t $ !$"#$t "+,$.
T*5($ 1 D$!&@n$# C+,$ 13 .
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 216/499
Input
The input will consist of data for a number of games. The input for each game begins with an integerspecifying N (the length of the code). Following these will be the secret code, represented as N integers, whichwe will limit to the range 1 to 9. There will then follow an arbitrary number of guesses, each also representedas N integers, each in the range 1 to 9. Following the last guess in each game will be N zeroes, these zeroes arenot to be considered as a guess. Following the data for the first game will appear data for the second game (ifany) beginning with a new value for N . The last game in the input will be followed by a single zero (when avalue for N would normally be specified). The maximum value for N will be 1000.
Output
The output for each game should list the hints that would be generated for each guess, in order, one hint perline. Each hint should be represented as a pair of integers enclosed in parentheses and separated by a comma.The entire list of hints for each game should be prefixed by a heading indicating the game number; games arenumbered sequentially starting with 1. Look at the samples below for the exact format.
0ample .nput
$1 3 " "1 1 2 3$ 3 3 "* " " 1* 1 3 "1 3 " "! ! ! !1!1 2 2 2 $ " * * * B1 2 3 $ " * < B 1
1 1 2 2 3 3 $ $ " "1 2 1 3 1 " 1 * 1 B1 2 2 " " " * * * <! ! ! ! ! ! ! ! ! !!
0ample :utput
ame 1:-1,1/-2,!/
-1,2/-1,2/-$,!/
ame 2:-2,$/-3,2/-",!/-<,!/
ICOM Challenge Programming Contest
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 217/499
March 4, 2000Beginner Division
Input File: isbn.inOutput File: isbn.outSource File: isbn.xxx
Recogni1ing +ood IS#N"
Problem Description
Most books now published are assigned a code which uniquely identifies the book. The International Standard BookNumber, or ISBN, is normally a sequence of 10 decimal digits, but in some cases, the capital letter X may also appear asthe tenth digit. Hyphens are included at various places in the ISBN to make them easier to read, but have no othersignificance. The sample input and expected output shown below illustrate many valid, and a few invalid, forms forISBNs.
Actually, only the first nine digits in an ISBN are used to identify a book. The tenth character serves as a check digit toverify that the preceding 9 digits are correctly formed. This check digit is selected so that the value computed as shown inthe following algorithm is evenly divisible by 11. Since the check digit may sometimes need to be as large as 10 toguarantee divisibility by 11, a special symbol was selected by the ISBN designers to represent 10, and that is the roleplayed by X.
The algorithm used to check an ISBN is relatively simple. Two sums, sl and s2, are computed over the digits of the ISBN,with s2 being the sum of the partial sums in sl after each digit of the ISBN is added to it. The ISBN is correct if the finalvalue of s2 is evenly divisible by 11.
An example will clarify the procedure: Consider the (correct) ISBN 0-13-162959-X (for Tanenbaum's ComputerNetworks). First look at the calculation of sl:
Digits in the ISBN 0 1 3 1 6 2 9 5 9 10 (X)
sl (partial sums) 0 1 4 5 11 13 22 27 36 46
The calculation of s2 is done by computing the total of the partial sums in the calculation of s1:
s2 (running totals) 0 1 5 10 21 3 4 5 6 8 3 119 16 5
We now verify the correctness of the ISBN by noting that 165 is, indeed, evenly divisible by 11.
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 218/499
Input
The input data for this problem will contain one candidate ISBN per line of input, perhaps preceded and/orfollowed by additional spaces. No line will contain more than 80 characters, but the candidate ISBN maycontain illegal characters, and more or fewer than the required 10 digits. Valid ISBNs may include hyphens atarbitrary locations. The end of file marks the end of the input data.
Output
The output should include a display of the candidate ISBN and a statement of whether it is legal or illegal. Theexpected output shown below illustrates the expected form.
Sample Input
0-89237-010-60-8306-3637-4
0-06-017758-6This_is_garbage
1-56884-030-60-8230-2571-3
0-345-31386-00-671-88858-70-8104-5687-70-671-74119-50-812-52030-00-345-24865-1-150
0-452-26740-40-13-139072-40-1315-2447-X
Sample Output
!D B23<D!1!D* is correct&!D 3!*D3*3<D$ is correct&!D!*D!1<<" D* is correct&'4isSisS arba e is incorrect&1D"* $D!3!D* is correct&!D 3!*D3*3<D$ is correct&!D!*D!1<<" D* is correct&1D"* $D!3!D* is correct&!D 23!D2"<1D3 is correct&!D3$"D313 *D! is correct&!D*<1D " D< is correct&!D 1!$D"* <D< is correct&!D*<1D<$11BD" is correct&!D 12D"2!3!D! is correct&!D3$"D2$ *"D1D1"! is incorrect&!D$"2D2*<$!D$ is correct&!D13D13B!<2D$ is correct&!D131"D2$$<D# is correct&
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 219/499
ICOM Challenge Programming ContestMarch4, 2000
Beginner Division
Input File: packets.inOutput File: packets.outSource File: packets.xxx
Packe!"
Problem Description
A factory produces products packed in square packets of the same height h and of the sizes 1x1, 2x2, 3x3, 4×4,5x5, 6x6. These products are always delivered to customers in the square parcels of the same height h as theproducts have and of the size 6x6. Because of the expenses it is the interest of the factory as well as of thecustomer to minimize the number of parcels necessary to deliver the ordered products from the factory to thecustomer. A good program solving the problem of finding the minimal number of parcels necessary to deliver the
given products according to an order would save a lot of money. You are asked to make such a program.
Input
The input file consists of several lines specifying orders. Each line specifies one order. Orders are described bysix integers separated by one space representing successively the number of packets of individual size from thesmallest size 1x1 to the biggest size 6x6. The end of the input file is indicated by the line containing six zeros.
Output
The output file contains one line for each line in the input file. This line contains the minimal number of parcelsinto which the order from the corresponding line of the input file can be packed. There is no line in the output filecorresponding to the last "null" line of the input file.
Sample Input
! ! $ ! ! 1< " 1 ! ! !! ! ! ! ! !
Sample Output
21
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 220/499
University o7 Puerto Rico-ayagueQ Campus
!"#$ "%allen&e **
+ pert -ivision
Sponsored by
AAAEICand Lucent Technologies
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 221/499
Table of Contents
Problem Page
AWESOME DECIMALS ...................................................................................................................3
TO CACHE OR NOT TO CACHE ....................................................................................................4OBSTACLES ...................................................................................................................................'7
A SIMPLE INTERPRETER .............................................................................................................l0
STRONGLY CONNECTED COMPONENTS ................................................................................13
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 222/499
ICOM C allenge Programming Con!e"!
@arch '", ')))
>pert 9ivision
Inpu! *ile: decimal",in
Butput ;ile! decimals.out
Source *ile: decimal",>999?
AKe"ome Decimal"
Problem Description
D*#$ t+ &n, * !t#&n@ t *t *,,! up t+ * @&)$n nu'5$#. T $ !t#&n@ &(( "+n!&!t + t $ ,&@&t! <> % &t +pt&+n*( p(u! % *n, '&nu! >% !&@n! 5$t $$n t $'. D&@&t! 5$t $$n t + !&!&n@($ ,$"&'*( nu'5$#. K *t ! t $ "*t" h Y+u *)$ t+ u!$ *(( ,$"&'*( ,&@&t!6 &n *!"$n,&n@ +#,t $ !*'p($ &nput *n, -+u &(( !$$.
Y+u# p#+@#*' &(( #$*, !$)$#*( &nt$@$#! #+' t $ &nput &($6 +n$ nu'5$# p$# (&n$. T $&(( *)$ +n$ (&n$ p$# $*" (&n$ + t $ &nput &($. F+# $*" nu'5$# &t * )*(&, !+(ut&+n6 t $*)$ t $ !+(ut&+n !t#&n@ +((+ $, 5- * !p*"$6 *n $ u*( X% !&@n6 *n+t $# !p*"$ *n, t $ nu'5$# t $#$ &! n+ !+(ut&+n +# t *t nu'5$#6 t $ (&n$ &(( *)$ t $ !t#&n@ T $#$ &! n+ !+(ut&+n +# +t $ nu'5$#. R$'$'5$# t+ p#&nt t $ !&@n *t t $ 5$@&nn&n@ $n #$ u&#$,.
Sample Input
23$"*<B $3"<$$"<*
Sample Output
D!1F23$"*< B % 23$"*<'4ere is no solution for B $3"<$F!1D23F$"D*<F B % $"D!1D2F3$F"*F< B % <*
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 223/499
.C:- Challenge Programming Contest
M*#" 136 1
E p$#t D&)&!&+n
.nput File( cache4in
:utput File( cache4outS+u#"$ F&($ "*" $.f Z
To Cac e or no! !o Cac e , , ,
Problem #escription
Y+u# 0+5 &! t+ '*?$ * !&'u(*t&+n + * '$'+#- !-!t$'6 *n, t+ @*t $# !t*t&!t&"! +n &t! p$# +&(( u!$ *"tu*( '$'+#- t#*"$! #+' t $ !+ t *#$ t *t &(( #un +n t $ !-!t$'. T $ !-!t$' *! * #$(*t&)$(- !'*
5ut *!t "*" $ '$'+#- *n, * (*#@$ 5ut !(+ RAM. T $ *,,#$!! !p*"$ &! 32 5&t! &,$6 *(( + &" *,,#$!!*5($. T $ "*" $ &! * ,&#$"t '*pp$, "*" $.
T $ &nput &($ &(( *)$ t $ +((+ &n@ &n +#'*t&+n
] Nu'5$# + 5-t$! &n n+#'*( '$'+#-] Nu'5$# + 5-t$! &n "*" $ '$'+#-] Nu'5$# + 5-t$! p$# "*" $ (&n$] M$'+#- *""$!!$! + * p+#t&+n + t $ "+,$
Y+u "*n *!!u'$ t $ +((+ &n@ *5+ut t $ &nput ,*t*
] A(( '$*!u#$! + t $ "*" $ *n, '$'+#- &#!t +u# &nput!% *#$ p+ $#! + t +] I f "*" $ !&8$ f M$'+#- !&8$ f 4GB] T $ "*" $ "*n +(, *t ($*!t +n$ "+'p($t$ !$t + (&n$!.] On(- +n$ p#+"$!!+# 5u! '*!t$#% *! *""$!! t+ t &! '$'+#- !-!t$'.
T $ +utput &(( *)$ * (&n$ p$# '$'+#- *""$!! &n"(u,$, &n t $ &nput &($. Y+u# p#+@#*' ! **""$!! #$!u(t$, +n * '&!! +# * &t6 *n, *t (&n$ + t $ "*" $ *! *""$!!$,.
;ints(
• S$$ t $ (*!t p*@$ + t &! p#+5($' +# * #$ #$! $# "+u#!$ +n "*" $!
0ample .nput
$23 2 1 3 ! $ $ $ " " * 3 3 3 " * < $ 3 < * " 1 1 $ " $ * <
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 224/499
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 225/499
Knowing what's in a cache line
A t*@ &! ?$pt +# $*" (&n$ !*)$, &n t $ "*" $. E*" t*@ &(( !$#)$ t+ ,$t$#'&n$ & t $ RAM"u##$nt *""$!! &! p*#t + &t! "+##$!p+n,&n@ (&n$. T*@! *#$ "+n!t#u"t$, 5- !*)&n@ t $ '+!t !*,,#$!!$! + t $ (+"*t&+n! + * (&n$. A(( (+"*t&+n! &n * (&n$ &(( ! *#$ t $ !*'$ *,,#$!! p#$ & . T $ 5&t! + t $ *,,#$!! ,$t$#'&n$ t $ + !$t + $*" (+"*t&+n #+' t $ !t*#t + t $ (&n$.
Associativity
T $ "*" $ '*- 5$ ,&)&,$, u#t $# &nt+ @#+up! + (&n$! "*(($, !$t!. E)$#- !$t *! t $ !*'$ !&8"+##$!p+n,! t+ * @#+up + (&n$! + RAM. E*" (&n$ +n t &! @#+up "*n 5$ p(*"$, &n *n- "+##$!p+n,&n@ !$t.
• D&#$"t '*pp$, "*" $ > K $n $*" !$t *! +n(- +n$ (&n$. T $#$ &! +n(- +n$ p+!!&5($ "*" $ (&n$ +# $*" (+"*t&+n + '$'+#-.
• Fu((- *!!+"&*t&)$ "*" $ > T $ +($ "*" $ &! +#'$, 5- * !&n@($ !$t. D*t* #+' RAM '*- 5$ +(&n$ + t $ "*" $.
• S$t *!!+"&*t&)$ "*" $ > T $#$ &! '+#$ t *n +n$ !$t &n t $ "*" $6 *n, $*" !$t *! n (&n$!. A (&n$ #+' RAM '
*n- + t $ n (&n$! + t $ "+##$!p+n,&n@ !$t. T &! "*" $ &! !*&, t+ 5$ n> *- !$t *!!+"&*t&)$.
N+t$ t *t $ &#!t t + t-p$! + "*" $! *#$ !p$"&*( "*!$! + !$t *!!+"&*t&)$ "*" $!.
Computing set number and tags
T $ &@u#$ 5$(+ ! + ! * *,,#$!!$! *#$ ,$"+'p+!$, t+ @&)$ t $&# "+##$!p+n,&n@ t*@6+ !$t. N+t$ t *t
• Nu'5$# + 5&t! n$$,$, +# 5(+"? + !$t X I+@2 "*" $ (&n$ !&8$%• Nu'5$# + 5&t! n$$,$, +# !$t nu'5$# X I+@2 nu'5$# + !$t!%• T $ #$!t + t $ *,,#$!! '*- 5$ u!$, +# t $ t*@
'>5&t *,,#$!!
T*@ S$t B(+"? O !$t
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 226/499
.C:- Challenge Programming Contest-arch &=J &VVV$5pert #ivision
Input F&($ +5!t*"($.&nOutput F&($ +5!t*"($.+ut
S+u#"$ F&($ +5!t*"($.f Z
Ob"!acle"
Problem #escription
A #+5+t '+)$! &n * #++' u(( + +5!t*"($!. G&)$n t $ p#$!$nt p+!&t&+n + t $ #+5+t6 &n, t+ * @&)$n ,$!t&n*t&+n6 *)+&,&n@ *n- +5!t*"($!. Y+u '*- *!!u'$ t $ +((+ &n@
• T $ #+5+t *n, t $ ,$!t&n*t&+n *)$ n+ !&8$.• A(( +5!t*"($! *#$ #$"t*n@u(*#.• T $#$ &! +n$ *n, +n(- +n$ ! +#t$!t )*(&, #+ut$ t+ t $ ,$!t&n*t&+n.• T $ #++' &! * ! u*#$ + '* &'u' !&8$ 4<• O5!t*"($! ,+ n+t t+u" +n$ *n+t $# • A(( "++#,&n*t$! *#$ @&)$n &n &nt$@$# nu'5$#!• T $#$ &(( 5$ n+ '+#$ t *n t$n 1<% +5!t*"($! &n *n- &nput !$t.
T $ &nput &($ "+nt*&n! !$ u$n"$ + &n,$p$n,$nt &nput !$t!. E*" !$t *! t $ +((+ &n@ &n +#
• T $ &n&t&*( p+!&t&+n + t $ #+5+t >- "++#,&n*t$!%• T $ ,$!t&n*t&+n p+&nt >- "++#,&n*t$!%•
T $ nu'5$# + +5!t*"($!• F+# $*" +5!t*"($ +n$ (&n$ p$# +5!t*"($%• T $ >"++#,&n*t$ + t $ ($ t !&,$• T $ >"++#,&n*t$ + t $ #&@ t !&,$• T $ ->"++#,&n*t$ + t $ t+p !&,$• T $ ->"++#,&n*t$ + t $ 5+tt+' !&,$
T $ +utput "+n!&!t! + * !$ u$n"$ + >- "++#,&n*t$! t *t #$p#$!$nt !u""$!!&)$ p+!&t& 5$t $$n !t#*&@ t>(&n$ '+)$!6 +((+ $, 5- t $ ,&!t*n"$ t#*)$($, 5- t $ #+5+t +)$# t $ ! +#t$!t p*t'+#$ t *n +n$ p*t &t t $ !*'$ ! +#t$!t ,&!t*n"$6 " +!$ t $ +n$ &t t $ (+ $!t nu'5$# + '+)$!. Y p#+@#*' ! +u(, &n, t $ *n! $# &n * #$*!+n*5($ *'+unt + t&'$. A!? t $ 0u,@$! +# &n!t#u"t&+n
t&'$ &! #$*!+n*5($.
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 227/499
0ample .nput
1 1B B1!1 2 $ 33 $ 3
" 1! 3 1B 1! " $" 1! < ** B 1! 11 B 1! 11 11 1!B 11 1!3 $ 1! B
0ample :utput
-1, 1/, -$, 3/, -", </, - , /, -B, B/=: 12&3!"1
;ints(
• C+n!&,$# #$p#$!$nt&n@ $*" +5!t*"($ 5- * !-!t$' + +u# &n$ u*(&t&$!. E*" '+)$#$p#$!$nt$, *! * !$@'$nt. I *n- p+&nt + t $ !$@'$nt !*t&! &$! t $ &n$ u*(&t&$!6 t $n)*(&,6 5$"*u!$ &t "#+!!$! *n +5!t*"($.
• An *(t$#n*t&)$ +u(, 5$ t+ #$p#$!$nt t $ p#+5($' !p*"$ u!&n@ * ,&#$"t$, @#*p 6 *n, ?n+ n *(@+#&t ' +# &n,&n@ t $ !&n@($>!+u#"$ ! +#t$!t p*t +n t $ ,&#$"t$, @#*p .
• N+t$ t *t t &! p#+5($' 5$"+'$! unt#*"t*5($ 5- u!&n@ +n(- 5#ut$ +#"$% +# '+#$ t *n *
+5!t*"($! O n 4%W%6 +#n +5!t*"($!%. A t$# *)&n@ -+u# p#+@#*' +#? +# * $ +5!t*"($&'p($'$nt * !&'p($ $u#&!t&" t+ p#un$ t $ !$*#" t#$$a &. $. ,u#&n@ t $ !$*#" 6 $(&'&n*+5)&+u!(- n+t 5$tt$# t *n t $ 5$!t p*t !+ *#.
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 228/499
Notes(
;ere is a picture 7or the sample input and output sho?n above4
0 1 2 3 4 5 6 7 8 9 10 11
11 11
10 10
9 9
8 8
7 7
6 6
5 5
4 4
3 3
2
1 1
0 0
0 1 2 3 4 5 6 7 8 9 10 11
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 229/499
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 230/499
(&n$ < &(( #$ $#$n"$ t $ &n,$ + t $ (++p t *t !t*#t! &n (&n$ <36 &($ (&n$ < &(( #$ $#$n"$(++p t *t !t*#t! &n (&n$ <:. L&n$ < &(( #$ $#$n"$ t $ &n,$ + t $ (++p t *t !t*#t! &n (&n$ <3.
K#&t$ * p#+@#*' t *t &(( &nt$#p#$t p#+@#*'! #&tt$n &n t $ n$ (*n@u*@$. Y+u# &nt$#t $ +((+ &n@ $##+#!
• An &n,$ + !$t +ut + 5+un,! t $#$ $ &!t! n+ (++p &n,$ *t t $ n$!t&n@ ($)$(!p$"& &$,% P#&nt O !$t +ut + 5+un,! +n * !&n@($ (&n$.
• In)*(&, (&t$#*( *(( (&t$#*(! ! +u(, 5$ un!&@n$, &nt$@$#! f 216 >1% P#&nt In)*(&, (&t$#*( !p$"& &!&n@($ (&n$.
• In)*(&, !-nt* . P#&nt S-nt* $##+# +n * !&n@($ (&n$.I *n $##+# &! ,$t$"t$,6 -+u# &nt$#p#$t$# ! +u(, *!!u'$ t *t t $ #$!t + t $ p#+@#*' &! * )*(&
&t! + n.
0ample .nput
pus4 1pus4 1!!mult 3$pus4pus4 **"3Bpus4 1pus4 1!for
pus4 1pus4 1pus4 "for
pus4 1pus4 !for
pus4 1pus4 !multprint
nextnext
Sample OutputS-nt* $##+# In)*(&, (&t$#*( !p$"& &$,O !$t +ut + 5+un,!1243:
4
121:
1<1
S&nt* E##+# #$!t*#t &t n$ t(&n$
In)*(&, L&t$#*( #$!t*#t &t n$ t (&n$
O !$t +ut + 5+un,! #$!t*#t &tn$ t (&n$
T &! !$@'$nt &! * "+'p($t$ p#+@#*'
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 231/499
2<2
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 232/499
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 233/499
Sample Input
1415522165
62326776733487438488
Sample Output12"3$*<8
Note:This input sample has only one set. Your program must accept multiple input sets
from the same file.
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 234/499
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 235/499
Table of Contents
Problem Page
DATABASE LOGGING TABLES ................................................................................................... 3
SUBSETS ......................................................................................................................................5WORD PUZZLE ++ .......................................................................................................................6
TELEPHONE DIRECTORY SEARCH ..........................................................................................8
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 236/499
ICOM Challenge Programming ContestMarch 13, 1999
Intermediate Division
Input File: dblog.inOutput File: dblog.out
Source File: dblog.<xxx>
Da!aba"e $ogging Table"
Problem Description
Most databases have a logging system that keeps track of all datamodifications. The log generated by this system aids in the recovery of the databaseafter a crash.
The data modifications are made through concurrent transactions that affect thedatabase. A transaction reads data, UPDATEs the data and saves it in a space intemporary memory, called a page. The transaction requests that all data updates it hasmade are COMMITted (i.e. written to disk). When all that data is written to disk, thetransaction has ENDed. In case of a database, system or disk error it is possible toABORT a transaction. The logging system keeps a chronological list of these actions.Each list record is of the form:
LSN Type TranslD PageID
Each record has a unique log sequence number (LSN). The type is the actionbeing executed by the transaction (update, commit, end or abort). The transID is the
identification number for the transaction. The pageID is the identification number for thepage being modified.
To provide a static image of the database state before a crash, the logging systemalso keeps track of active transactions and modified pages. Two tables are used forthis purpose:
• A dirty page table (DPT) keeps track of the pages in use. It stores the pageID of themodified page and the LSN, called recLSN, of the first log record that caused thepage to become dirty. Once the transaction that causes the page to become dirtyends or is aborted, the page record in the table is erased.
•
A transaction table (TT) contains one entry for each active transaction. The entrycontains the transID, the LSN of the most recent log record for this transaction(called lastLSN) and the status of the transaction that is in process (active,aborted or commited). Once the transaction is ended or aborted its record inthe table is erased.
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 237/499
G&)$n t $ (+@ #$"+#,!6 #$"+n!t#u"t t $ ,&#t- p*@$ *n, t#*n!*"t&+n t*5($!.S + t $ p#+"$!! t *t #$"+n!t#u"t! t $ t*5($!. Input &($ ,5(+@.&n "+nt*&n! t $ (+@#$"+#,! &n t $ +#'*t
LSN type: transID pageID
The output file dblog.out should contain the dirty page table and transactiontable in the format:
LSN: DPT=[pageID,recLSN),...],TT=[(transID,lastLSN,status),..]
Notes
• A transaction is active if it has made an update and is not committed,aborted or ended.
• Only update records require pageID S .• A page is not taken off the dirty page table until all transactions that modifiedit are either committed/ended or aborted.
Sample Input
10 update: T1 P120 commit: TI30 end: TI
40 update: T2 P250 update: T3 P360 update: T2 P370 abort: T280 update: T4 P590 update: T4 P4100 commit: T3
S*'p($ Output
10: DPT=[(P1,10)], TT=[(T1, 10, a)]
20: DPT=[(P1,10)], TT=[(T1, 20, c)]30: DPT=[], TT=[]40: DPT=[(P2,40)], TT=[(T2, 40, a)]50: DPT=[(P2,40), (P3,50)], TT=[(T2, 40, a), (T3,50,a)]60: DPT=[(P2,40), (P3,50)], TT=[(T2, 60, a), (T3,50,a)]70: DPT=[(P2,40), (P3,50)], TT=[(T2, 60, b), (T3,50,a)]80: DPT=[(P3,50), (P5,80)], TT=[(T3,50,a), (T4,80,a)]90: DPT=[(P3,50), (P5,80), (P4, 90)], TT=[(T3,50,a), (T4,90,a)]100: DPT=[(P3,50), (P5,80), (P4, 90)], TT=[(T3,100,c), T4,90,a)]
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 238/499
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 239/499
ICOM Challenge Programming ContestMarch 13, 1999
Intermediate Division
@ord PuQQle ^^
Input File: puzzle2.inOutput file: puzzle2.outSource File: puzzle2.<xxx>
Puzzle Description
In a word puzzle you are given a list of words and a grid of letters. Theobjective of the game is to find all listed words embedded in the grid of letters.The words can be found horizontally, vertically or diagonally. In this variation ofthe game, words can also appear twisted (see figure below).
Make a program that will solve a word puzzle. Your program must find allwords present and output the position of each letter of the word on the grid. Theinput file consists of the dimension of the grid, the grid of letters and a list ofwords to find.
The output file will be the list of letters, followed by the coordinate of everyletter of the word, or the string "not found".
t c n j 1 p
g w i s u r
o e o z t g
o b z r e h
d l m h d i
e h e l l o
Sample Input
*'CLN P9;75
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 240/499
OEOZTGOBZREH DLMHDIEHELLOpuzzlewordproblem
hellotwistedarrayinputoutput
ample Butput
puzzle (0, 5) (1, 4) (2, 3) (3, 2) (4, 1) (5, 0)word (1, 1) (2, 2) (3, 3) (4, 4)problem not foundhello (5, 1) (5, 2) (5, 3) (5, 4)twisted (0, 0) (1, 1) (1, 2) (1, 3) (2, 4) (3, 4) (4, 4)array not foundinput not foundoutput not found
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 241/499
AEIC Challenge Programming ContestMarch 13, 1999
Intermediate Division
Input File: teldir. inOutput File: teldir. out
Source File: teldir.<xxx>
Telep one Direc!or% Searc
Problem Description
Some voice mail systems allow users to search for phone numbers of otherregistered users of the system. To do so, one must spell the name or a. prefix of thename of the person to call. This is accomplished by pressing the key numbercorresponding to each letter of the prefix.
Use the following diagram to map numbers on the keypad to letters.
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 242/499
Write a program that finds all names in the directory that match a given nameprefix. The prefix is given as a sequence of keypad presses. Begin by matching the lastname and then the first name.
The input will consist of:
• Number of names/records in the dictionary• List of names in the dictionary• Number of keypad numeric sequences• Numeric sequences (one per line).
The maximum number of characters in the number sequence is 11. Allow 32bytes for names.
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 243/499
The output file consists of the numeric sequence followed by the list ofnames that matched the sequence or the message "No Matches Found".
Sample Input
10Velez, Carlos
Torres, AnaJolie, AngelinaLopez, MaribelLaguerre, TonyLoperena, MarthaSantos, BenjaminKorg, JamesKlinger, HeidiQuestell, Eduardo42345
567567375
Sample Output
Sequence: 2345Result:No Matches Found
Sequence: 567Results:Lopez, MaribelLoperena, MarthaKorg, James
Sequence: 56737Results:Loperena, Martha
Sequence: 5Results:Jolie, Angelina
Lopez, MaribelLaguerre, TonyLoperena, MarthaKorg, JamesKlinger, Heidi
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 244/499
0ni.er"i!% of Puer!o RicoMa%ague1 Campu"
!"#$ "%allen&e ** Beginner Division
Sponsored by
AEICand Lucent Technologies
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 245/499
Table of Con!en!"
Problem Page
PARITY BIT………..…………………………………………………………………….…..3
XMORSE………………………………………………………….………………..……......6
Y2K PROBLEM….………………………………………………………………………..…8
THE BART CHALLENGE…………………………………………………………………10
WORD PUZZLE……………………………………………………………………………11
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 246/499
Input File: parity.inOutput File: parity.out
Source File: parity.<xxx>
Pari!% C ecking
Problem #escription
P$# *p! t $ !&'p($!t +#' + t#*n!'&!!&+n $##+# ,$t$"t&+n &! p*#&t- " $"?&n@ p*#&t- + * !$t + ,*t* &! t $ p*#&t- + t $ nu'5$# + 5&t! &t )*(u$ + 1 &n t $ ,*t*F+# $ *'p($6 t $ ,*t* <<11<<1< *! *n +,, p*#&t-6 &($ <111<<1< *! *n $)$n p*#&t-.
In * t#*n!'&!!&+n !-!t$'6 t $ !$n,$# + t $ ,*t* &(( 5un,($ $*" ,*t* p*"?$t&t *n *,,&t&+n*( 5&t t *t &(( +#"$ t $ p*#&t- + t $ +($ t+ 5$ $)$n +# +,,6
,$p$n,&n@ +n *t p*#&t- t $ #$"$&)$# *n, !$n,$# *)$ *@#$$, up+n. T $ #$"$&)$# t $n *!!u'$ t *t *(( "+##$"t p*"?$t! *)$ t *t p*#&t-. An- p*"?$t! &t &n"+##$"t p*#&&(( 5$ ,&!"*#,$, *n, #$!$nt.
T $ ,#* 5*"? + t &! '$t +, &! t *t n+ '+#$ t *n +n$ $##+# '*- 5$ ,$t$"t$,.Fu#t $#'+#$6 $n t $ $##+# &! ,$t$"t$,6 t $ ,*t* "*nn+t 5$ "+##$"t$,. T $ p*"?$t *! t+ 5$ #$!$nt #+' t $ +t $# !&,$ + t $ t#*n!'&!!&+n " *nn$(.
B- u!&n@ t +>,&'$n!&+n*( p*#&t- " $"?&n@6 '+#$ t *n +n$ $##+# '*- ,$t$"t$,. I t $#$ &! +n(- +n$ $##+#6 t $ ,*t* '*- 5$ "+##$"t$,6 *)+&,&n@ #$!$n,!. In t,&'$n!&+n*( p*#&t- " $"?&n@6 * @#+up + ,*t* *n, p*#&t- 5&t p*"?$t! *#$ 5un,($, t*n, *n *,,&t&+n*( p*#&t- p*"?$t &! @$n$#*t$, u!&n@ $*" + t $ p*"?$t! &n t $ @#*,,&t&+n*( p*"?$t *! p*#&t- 5&t! +# $*" "+(u'n 5&t p+!&t&+n% + t $ ,*t* p*"?$t $&# "+##$!p+n,&n@ p*#&t- 5&t!. T $ +((+ &n@ &! * @#+up + ,*t* *n, p*#&t- 5+((+ $, 5- * p*#&t- p*"?$t.
PacketNumber
Data (four bits) ParityBit
0 0 0 1 1 01 1 0 1 0 0234
001
101
011
001
110
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 247/499
Y+u# p#+@#*' &(( ,$t$"t $##+#! &n * !$t + p*"?$t!. I t $#$ &! +n(- +n$ $##+#6 &t &(t $ $##+# *n, ! + $#$ t $ $##+# +""u##$,. Y+u '*- *!!u'$ t $ p*#&t- p*"?$t &((
n$)$# 5$ "+##upt$,.
T $ &nput &(( "+n!&!t + * !$ u$n"$ + &nput !$t!. E*" &nput !$t &(( "+##$!p+n, !$t + p*"?$t!. F+# $*" &nput !$t6 -+u# p#+@#*' &(( #$*,
• T $ nu'5$# + p*"?$t! n% +n t &! !$t• T $ ($n@t &n 5&t!% + t $ p*"?$t!• N p*"?$t!
F+# $*" &nput !$t6 -+u# p#+@#*' &(( ! + t $ +((+ &n@
• T $ !$ u$n"$ + p*"?$t! +n t $ !$t & t $#$ *! +n(- +n$ $##+#6 t $"+##$!p+n,&n@ 5&t 'u!t 5$ "+##$"t$, *n, ! + n "+##$"t$,%
• I '+#$ t *n +n$ $##+# &! ,$t$"t$,6 '*#? t $ #+ ! *n, "+(u'n! $#$ t $ $##+#*#$ &t *n *!t$#&!? t+ t $ #&@ t +# 5+tt+'6 #$!p$"t&)$(-.
0ample .nput
"*!!11!!111!1!!1!!1!!!1!1!1111!!3$!!11!1!1!11!$3!1111111!!!!
0ample :utput
!!11!!111!1!!1!!1!!!1!1!1111!! = =!!11!1!1!11!
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 248/499
!111!111!!!!Error corrected in pac et 1, bit 1&
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 249/499
Input File: xmorse.inOutput File: xmorse.out
Source File: xmorse.<xxx>
-Mor"e
Problem Description
FBI A@$nt! F+ Mu(,$# *n, D*n* S"u((- *#$ +((+ &n@ * n$ ($*, &n t $&# '+#$"$nt ;>F&($! "*!$. T $- 0u!t #$"$&)$, * t+p !$"#$t ,*t* &($ t #+u@ un+ &"&*( " *t *t "*n p#+)&,$ t $' &t )$#- )*(u*5($ &n +#'*t&+n *5+ut t $ "*!$ t $- *#$ +#?&n@+n. T $ &n +#'*t&+n &n t $ &($ *pp$*#! t+ 5$ $n"#-pt$, &t * !$#&$! + . *n, >A@$nt! 5$(&$)$ t *t t $ '$!!*@$ &! $n"+,$, u!&n@ * @#*p &"*( #$p#$!$nt*t&+n +"+,$. M+#!$ "+,$ #$p#$!$nt! " *#*"t$#! + *n *(p *5$t *! !$ u$n"$! + ,&t! ! +#t ?$-"(+!u#$!% *n, ,* ! (+n@$# ?$- "(+!u#$!%. I $ ($t * p$#&+, .% #$p#$!$nt * ,&t *n, *>% #$p#$!$nt * ,* 6 t $n t $ M+#!$ "+,$ )$#!&+n + t $ En@(&! *(p *5$t "*n
#$p#$!$nt$, *!
A .> N >.B >... O >>>C >.>. P .>>.D >.. >>.>E . R .>.F ..>. S ...G >>. T >J . U ..>I .. V ...>H .>>> K .>>
>.> ; >..>L .>.. Y >.>>M >> >>..
J$(p A@$nt! Mu(,$# *n, S"u((- t+ ,$"+,$ t $ !$"#$t '$!!*@$ 5- #&t&n@ * p#+@#*' t *t &(( &nt$#p#$t t $ &n +#'*t&+n &n M+#!$ "+,$ *! En@(&! .
T $ &nput &($ "+nt*&n! p$#&+,! *n, ,*! $! #$p#$!$nt&n@ * '$!!*@$ "+'p++n(- + t $ En@(&! *(p *5$t *! !p$"& &$, *5+)$. On$ 5(*n? !p*"$ &! u!$, t+ !$p*#($tt$#! *n, t #$$ 5(*n?! *#$ u!$, t+ !$p*#*t$ +#,!.
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 250/499
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 251/499
Input File: y2k.inOutput File: y2k.out
Source File: y2k.<xxx>
4 Problem
Problem Description
The Year 2000 problem stems from the fact that, in many computer systemsand databases, the year component of the date is represented by two decimal digits. Ifa person's date of birth (in months/day/year format) is 04/25/92, the apparent age ofthe person would be 6 years old. But was the person born in 1892 or 1992?
Here are some rules that can be used to determine a person's age:
Rule 1 : All persons in the input data will have been born on or before the date of thiscontest (March 13, 1999), this means:
• If the last two digits of the year of birth are 99 and the date within that yearis in the range from March 14 through December 31 1999, then the year ofbirth is 1899.
Rule 2 : If the apparent age is 20 or more, the first two digits of the year of birth are 19.
Rule 3 : If the apparent age is in the range of 7-19, then the existence of school recordswill determine the first two digits of the year. If the person attended school during thepast ten years, then the first two digits of the year of birth are 19, otherwise they are18.
Rule 4 : If the apparent age is 6 or less, then the existence of tax records will determinethe first two digits of the year of birth. If there is a tax record for the person, the first twodigits of the year of birth are 18; otherwise they are 19.
You may assume that all cases that arise in the input data will be covered bythe rules just stated.
Each line of the input consists of seven fields. Adjacent fields are separated byone blank space. The meaning of each field of the seven fields of inputs follows:
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 252/499
C+(u'n! 1>2 t $ p$#!+nd! n*'$
C+(u'n! 2 >3 t $ p$#!+n !+"&*( !$"u#&t- nu'5$#
C+(u'n! 3 >4< * 4 " *#*"t$# "+,$ &" ,$!&@n*t$! t $ (*!t ?n+ n
!" ++( *tt$n,$, 5- t $ p$#!+n ,u#&n@ t $ p*!t t$n
-$*#!. T $ "+,$ [>>>>[ '$*n! t *t t $ p$#!+n ,&, n+t *tt$n, !" ++(
,u#&n@ t *t p$#&+,.
C+(u'n! 42>43 t $ (*!t t + ,&@&t! + t $ '+!t #$"$nt -$*# &n &"
t $ p$#!+n &($, * t* #$tu#n6 & * t* #$tu#n &! ?n+ n
t+ *)$ 5$$n &($, !&n"$ 1 <. Ot $# &!$6 t $#$ &! n+ t* #$"+#, +# t &!
p$#!+n6 "+(u'n 42 &(( 5$ 5(*n? *n, "+(u'n 43 &(( "+nt*&n t $ !&n@($
,&@&t <.
C+(u'n! 4 >4: t $ p$#!+nd! '+nt + 5&#t
C+(u'n! 4 >4 t $ ,*- + t $ '+nt + t $ p$#!+nd! ,*t$ + 5&#t
C+(u'n! 1> 2 t $ (*!t t + ,&@&t! + t $ p$#!+nd! -$*# + 5&#t +#
0u!t t $ (*!t t + ,&@&t!6 & t $ p$#!+n *! 5+#n &n t $
p$#&+, 1 <<>1 < %
If the data in columns 45-46, or columns 48-49, or columns 51-52 requires onlyone digit, it will be right-justified in the stated columns. Your program will write itsoutput to the file y2k.out Each line in the input will give rise to an almost identical line ofoutput, the only differences been that the two-digit year of birth from columns 51-52 willbe replaced by a four-digit year of birth in columns 51-54. The first two digits of theyear of birth will be 18 or 19, determined by the set of rules provided.
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 253/499
Sample Input
=i8 stra, Ed ar *!3 $B"*2 DDDD ! B 1 BB
Lopper, race Murray 23$2" !3! DDDD B< 2 12 !
Lollerit4, Lerman *!23$ <$ J ;L B< " 2! <<
;4annon, Claude "<1 3B$ ! J OL B* 1! 2 <B
ovelace, 6da 1 3!BB 31 >6M; ! * 3! B2
>abba e, C4arles $1B3!B 23 DDDD ! 31 B2
Sample Output
=i8 stra, Ed ar *!3 $B"*2 ! B 1 1 BBLopper, race Murray 23$2" !3! B< 2 12 1B!!Lollerit4, Lerman *!23$ <$ J ;L B< " 2! 1B<<
;4annon, Claude "<1 3B$ ! J OL B* 1! 2 1B<Bovelace, 6da 1 3!BB 31 >6M; ! * 3! 1BB2>abba e, C4arles $1B3!B 23 ! 31 1 B2
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 254/499
Input File: bart.inOutput File: bart.out
Source File: bart.<xxx>
T e #ar! C allengeProblem Description
A t$# '*?&n@ * pu#" *!$ *t t $ "+'&" 5++? !t+#$6 B*#t S&'p!+n " *n@$ *! 1 "$nt!. J$ #$"$&)$, 1
,&'$6 1 n&"?$(6 *n, 2 p$nn&$!. L*t$# t *t ,*-6 J$ *! ! +pp&n@ *t * "+n)$n&$n"$ !t+#$. A@*&n &
" *n@$ *! 1 "$nt!. T &! t&'$ $ #$"$&)$, 2 n&"?$(! *n, p$nn&$!. J$ 5$@*n t+ +n,$# J+
'*n- !t+#$! "*n I ! +p &n *n, #$"$&)$ 1 "$nt! " *n@$ &n * ,& $#$nt "+n &@u#*t&+n + "+&n!h A
!u&t*5($ '$nt*( !t#u@@($6 $ ,$"&,$, t $ *n! $# *! :. J$ t $n " *(($n@$, -+u t+ "+n!&,$# t $
@$n$#*( p#+5($'.
K#&t$ * p#+@#*' t *t &(( ,$t$#'&n$ t $ nu'5$# + ,& $#$nt "+'5&n*t&+n! + U"+&n! p$nn-6 n&"?$(6 ,&'$6 u*#t$#6 *( >,+((*#% &" '*- 5$ u!$, t+ p#+,u"$ * @&*'+unt + '+n$-.
T $ &nput &(( "+n!&!t + * !$t + nu'5$#! 5$t $$n < *n, 6 &n"(u!&)$a +n$ p$(&n$ &n t $ &nput &($.
T $ +utput &(( "+n!&!t + t $ *pp#+p#&*t$ !t*t$'$nt #+' t $ !$($"t&+n 5$(+ a +n* !&n@($ (&n$ &n t $ +utput &($ +# $*" &nput )*(u$. T $ nu'5$#m &! t $ nu'5$# -+u#
p#+@#*' "+'put$!6n &! t $ &nput )*(u$.'4ere are m ways to produce n cents c4an e&'4ere is only 1 way to produce n cents c4an e&
S*'p($ Input
17114
S*'p($ OutputThere are 6 ways to produce 17 cents change.There are 4 ways to produce 11 cents change.There is only 1 way to produce 4 cents change.
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 255/499
Input File: puzzle.inOutput file: puzzle.out
Source File: puzzle.<xxx>
6ord Pu11le
Puzzle Description
In a word puzzle you are given a list of words and a grid of letters. Theobjective of the game is to find all listed words embedded in the grid of letters.The words can be found horizontally, vertically or diagonally.
Make a program that will solve a word puzzle. Your program must find allwords present and output the position of the first and last letters of the word onthe grid. The input file consists of the dimension of the grid, the grid of lettersand a list of words to find.
The output file will be the list of letters, followed by the starting coordinateand ending coordinate, or the string "not found".
h c n j 1 p
g w f k u r
o e o z c g
o b z r k h
d 1 m h d i
e h e 1 1 o
The following figure depicts the grid used in the example below.
Sample Input
*6CNO P
J 75
KEK C
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 256/499
K> 5 L= ML=9ELE KpuHHlewordproblem4elloarray
inputoutput
Sample Output
puzzle (0, 5) (5, O)word (1, 1) (4, 4)problem not foundhello (5, 1) (5, 5)array not foundinput not found
output not found
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 257/499
University of Puerto Rico Mayaguez Campus
!"#$ "%allen&e *
Expert Division
Sponsored by
AEIC and Lucent Technologies
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 258/499
Contents
1. Problem # 1 Code Generator2. Problem # 2 Knight Tour3. Problem # 3 DNA translation4. Problem # 4 Etruscan Calculator5. Problem # 5 Cybervision
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 259/499
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 260/499
5. As few temporaries as possible should be used(given the aboverestrictions).
:. F+# $*" +p$#*t+# &n t $ $ p#$!!&+n6 t $ '&n&'u' nu'5$# + &n!t#u"t&+n! 'u!t 5$@$n$#*t$, @&)$n t $ *5+)$ #$!t#&"t&+n!%.
7. The last instruction will leave the result of the expression on theregister.
Sample Input
AB+CD+EF++GH+++AB+CD+-AB/CD//
Sample Output
load Aadd Bstr $1load C
add Dstr $2load Eadd Fadd $2str $2load Gadd Hadd $2add $1
load Aadd Bstr $1load Cadd Dnegadd $1
load Adiv Bstr $1load Cdiv Dstr $2load $1div $2
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 261/499
Input File: knight.inOutput File: knight.out
Source File: knight.[xxx]
nig ! Tour
Problem Description
On chess, the knight piece has one of the most complicated moves. Youcan think of the Knight's move as an "L". It moves two squares eitherhorizontally or vertically and then makes a right angle turn for one more square.It can also move one square either horizontally or vertically and then make aright angle turn for two more squares. In the figure below, the knight ( K), canmove to any of the squares occupied by the pawns( P ).
T $ +50$t&)$ + t &! p#+5($' &!6 @&)$n * !t*#t&n@ "++#,&n*t$ +# t $ ?n&@ t6 t+ '+)$ &t*(( t $ ! u*#$! &n t $ 5+*#,6 )&!&t&n@ $*" ! u*#$ +n(- +n"$. A ! u*#$ &! &,$nt& &$, 5- &t! "++#F+# $ *'p($ t $ ! u*#$ +n t $ t+p #&@ t "+#n$# &! 161%. T $ +n$ n$ t t+ &t &! 162%. Output #+' t $ p#+@#*' ! +u(, 5$ * !$ u$n"$ + :4 "++#,&n*t$!. T $#$ &(( 5$ $&@ t "++#,&n*t$! p$# (&n$. E*""++#,&n*t$ !$p*#*t$, #+' t $ n$ t 5- * 5(*n? !p*"$.
Notes:
There is more than one correct answer for each input. Your programmust print only oneNote that brute force will not achieve a correct answer in areasonable time. You should use the knowledge about themovement of the Knight to limit the search. Your solution shouldattain a correct answer in a reasonable time.
Sample Input
1 1
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 262/499
Sample Output
1 12 33 11 22 41 62 84 76 88 77 58 37 15 27 38 16 24 12 21 42 61 83 75 87 78 56 67 88 6
42
: 14 22 11 33 2 14 33 43 321 3 4 : 4
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 263/499
:4 4: 3 4 2 3: 4 :3 4124 3 : : :
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 264/499
Input File: dna.inOutput File: dna.out
Source File: dna.[xxx]
DNA Tran"la!ion
Problem Description
Deoxyribonucleic acid (DNA) is composed of a sequence of nucleotide basespaired together to form a double-stranded helix structure. Through a series of complexbiochemical processes the nucleotide sequences in an organism's DNA are translatedinto proteins it requires for life. The object of this problem is to write a computerprogram which accepts a DNA strand and reports the protein generated, if any, fromthe DNA strand.
The nucleotide bases from which DNA is built are adenine, cytosine, guanineand thymine (hereafter referred to as A, C, G and T, respectively). These bases bondtogether in a chain to form half of a DNA strand. The other half of the DNA strand is asimilar chain, but each nucleotide is replaced by its complementary base. The bases Aand T are complementary, as are the bases C and G. These two "half-strands" of DNAare then bonded by pairing of the complementary bases to form a strand of DNA.
Typically a DNA strand is listed by simply writing down the bases which formthe primary strand (the complementary strand can always be created by writing thecomplements of the bases in the primary strand). For example, the sequenceTACTCGTAATTCACT represents a DNA strand whose complement would beATGAGCATTAAGTGA. Note that A is always paired with T, and C us always pairedwith G.
From a primary strand of DNA, a strand of ribonucleic acid (RNA) known asmessenger RNA (mRNA for short) is produced in a process known as transcription. Thetranscribed mRNA is identical to the complementary DNA strand with the exception thatthymine is replaced by a nucleotide known as uracil (hereafter referred as ti U). Forexample, the mRNA strand for the DNA in the previous paragraph would beAUGAGCAUUAAGUGA.
It is the sequence of bases in-the mRNA which determines the protein that willbe synthesized. The bases in the mRNA can be viewed as a collection codons, eachcodon having exactly three bases. The codon AUG marks the start of a proteinsequence, and any of the condons UAA, UAG or UGA marks the end of sequence. The
one or more condons between the start and termination codons represent thesequence of amino acids to be s*nthesized to form a protein. ;or e>ample, them3C8 codon 8I4 corresponds to the amino acid serine + er , 8UUcorresponds to isoleucine +6Le , and 88I corresponds to l*sine +L*s . o, theprotein formed from the e>ample m3C8 in the previous paragraph is, in itsabbreviated form erGlLeGL*s.
The complete genetic code from which codons are translated into amino acidsis shown in the table below (note that only the amino acid abbreviations areshown). It should also be noted that the sequence AUG, which has already
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 265/499
been identified as the start sequence, can also correspond to the amino acidmethionine (Met), So, the first AUG in a mRNA strand is the start sequence, butsubsequent AUG codons are translated normally into Met amino acid.
First base in codon Second base in codon........ .. ..Third base in codon U C A GU Phe Ser Tyr Cys............................U
Phe Ser Tyr Cys............................CLeu Ser --- --- ALeu Ser --- Trp............................G
C Leu Pro His Arg............................ULeu Pro His Arg............................CLeu Pro Gin Arg............................ALeu Pro Gin Arg............................G
A lie Thr Asn Ser............................Ulie Thr Asn Ser............................Clie Thr Lys Arg............................AMet Thr Lys Arg............................G
G Val Ala Asp Gly............................UVal Ala Asp Gly............................CVal Ala Glu Gly............................AVal Ala Glu Gly............................G
The input for this program consists of strands of DNA sequences, one strandper line, from which the protein it generates, if any, should be determined andoutput. The given DNA strand may be either the primary or the complimentaryDNA strand, and it may appear in either forward or reverse order, and the startand termination sequences do not necessarily appear at the ends of the strand.For example, a given input DNA strand to form the protein Ser-iLe-Lys could beany of ATACTCGTAATTCACTCC, CCTCACTTAATGCTCATA,TATGAGCATTAAGTGAGG or GGAGTGAATTACGAGTAT. The input file willbe determined by a line containing a single asterisk character.
You may assume the input to contain only valid, upper-case, DNA nucleotidebase letters (A, C, G and T). No input line will exceed 255 characters in length.There will be no blank lines or spaces in the input. Some sequences, thoughvalid DNA strands, do not produce valid protein sequences; the string "*** Notranslatable DNA found ***" should be output when an input DNA strand doesnot translate into a valid protein.
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 266/499
0ample .nput
ATACTC9TAATTCACTCC
CACCTGTACACAGAGGTAACTTAG
Sample Output
0er>.le>!ys
Cys>!eu>;is
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 267/499
ICOM Challenge Programming ContestMarch 28, 1998 Expert Division
Input File: calc.inOutput File: calc.out
. Source File: calc.[cpf]
T e E!ru"can Calcula!or
Problem Description
The two properties of arithmetic operators which determine the order inwhich they are executed in an expression are their precedence level and theirassociativity. Precedence levels determine the order in which differentoperatom are executed. Associativities determine the order in which a repeatedoperator is executed. Left associative operators are evaluated left to right whileright associative operators are evaluated right to left. Different operators withequal precedence levels are evaluated left to right. For example:
· If the precedence level of * is higher than that of +, the expression5*3+4 would evaluate to 19.
· If the precedence level of + is higher than that of *, the expression5' 3 + 4 would evaluate to 3 5.
· Left-associativity of - would cause the expression 3-2-1 to beinterpreted as (3-2)-1 which evaluates to o.
· Right-associativity of - would cause 3-2-1 to be interpreted as 3-(2-
1) which evaluates to 2.
Archaeologists have unearthed new evidence that indicates theEtruscans, ancient inhabitants of what we now call Italy, had a fairly complexarithmetic system. The operations used where the usual binary operations, butthe symbols used, their precedence and their associativities, vary widely acrossthe region. Your team is to write a program that will implement a simple integerEtruscan calculator with operations +, -, *, and /, where / denotes integerdivision. The catch is, your calculator has to deal with all of the local dialects.
The input file will contain 4 lines that describe the rules of precedenceand associativity for each symbol, followed by one or more lines eachcontaining an expression using the new symbol set to be evaluated. The firstfour lines each contain a four character string c 1c2c3c4 beginning in column one,where:
C 1 denotes the standard operator that is being described
C 2 denotes the local symbol being used for that operator
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 268/499
C 3 is a digit denoting the local precedence of the operator (higher digit meanshigher precedence)
C 4 is a single letter denoting the Joeal associativity of the operator (L for leftassociativity, R for right).
The line
-@1R
means that the symbol @ will be used to denote minus which will be right associativeand have precedence 1. The expression 5@3@1 under these circumstances willevaluate to 3.
For each input expression, your program must print one line containing theexpression with standard operators followed by a space, an equal sign, and the result.
Sample Input
+@1L-+3R*-2R//2R1@15@5+42@3@1 2/6/5+3
Sample Output
1+1=25+5-4 = 62+3*12/6/5-3= 14
Notes: The last expression, parenthesized to show you the order of execution is (2+((3*12) / (6/(5-3) ) ) ).Although the Etruscan civilization existed, little is known about their arithmetic systemand its written form. The characteristics we attribute to their system in this problem arepurely fictional.
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 269/499
Input File: vision.inOutput File: vision.outS+u#"$ F&($ )&!&+n.Q"p
C%ber.i"ion
Problem Description
Jayuya Robotics Inc., a local robot manufacturer, has asked for your helpto develop the software for the automatic recognition feature of their robot visionsystem. Their robots have cameras that capture images of the working space,and moving arms that can lift and move objects to and from any point inside theworking space. Your module must recognize objects on an image grabbed bythe camera, and report their position to a higher-level module.
An image can be represented by a 2-dimensional matrix of pixels. Thecamera captures pictorial information using a 2-dimensional grid of sensors ,such that each sensor has a corresponding pixel in the image. Light intensityinformation gets digitally coded into pixels according to an intensity scale. In abinary image, the scale has only two possible codes: 1 for high intensity and 0for Iow intensity.
Jayuya's robots capture binary images only. Objects to be recognizedare dark (Iow intensity) and the background is bright (high intensity), as permanufacturer's specifications.
Your job is to develop a program that takes a binary image, finds anyobjects in it, and outputs their position (2-dimensional center of mass) relative tothe pixel in the upper-left corner of the image. The coordinates for the pixel onthe upper-left corner are (0,0). The center of mass C(x~,yc) should be computedusing the equations:
where np is the number of pixels that belong to the object.
Objects can have any shape and size. The following rules may be usedto identify objects:
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 270/499
(1) If a pixel is 0 (dark), then it belongs to an object. If a pixel is I (bright)it belongs to the background.
(2) Pixels on the border of the image cannot be dark.(3) Objects are formed by one or more connected dark pixels. Two dark
pixels are connected if their x and y coordinates differ by at most 1(i.e. For all 1 < i < n ,1 < j < m , where n is the height and m is thewidth of the image, If pixel P(i,j) is dark, then all dark pixels P(p,q),such that i-1 < p < i + 1 and j - 1< q < j + 1, belong to the sameobject).
Hint: First, use the rules above to find out what object each pixel belongs to,and then compute the center of mass for each object using the coordinates ofeach pixel of that object.
0ample .nput
The first line contains the height and width of the image, in that order.This is followed by the matrix of pixels. Each row is in a new line. There are nospaces between column pixels. Your program must handle image up to 50x50in size.
10 201111111111111111111111111111111111111111111001110011100011111110010100110010011111100000001001110011
1110000000101101101111111000111001110011111111011111001001111111111111111000111111111111111111111111
Sample Output
The input image contains 3 objects.(6.000,4.111)(14.000,5.000)(14.000,5.000)
Centers of mass must be sorted by increasing x (column) coordinate. Incase there are centers of mass with equal x coordinates, they must be orderedfurther by increasing y (row) coordinate. Note that the coordinates are roundedto the nearest thousandth.
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 271/499
University of Puerto RicoMayaguez Campus
!"#$ "%allen&e * Intermediate Division
Sponsored by AEIC and Lucent Technologies
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 272/499
Contents
1. Problem#1 Egyptian Multiplication2. Problem#2 Queen Tour3. Problem#3 On the Sidewalk4. Problem#4 Game of Life5. Problem#5 Galactic Import
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 273/499
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 274/499
ou are to Frite a program to perform this g*ptian multiplication. 6nput Fillconsist of several pairs of nonzero numbers Fritten in g*ptian s*stem described above.Jhere Fill be one number per lineM each number Fill consist of groups of s*mbols, andeach group is terminated b* a single space +including the last group .
;or each pair of numbers, *our program should print the steps described aboveused in g*ptian multiplication. Cumbers in the left column should be in line Fith the leftmargin. ach number in the left and right column Fill be represented b* groups ofs*mbols, and each group is terminated b* a single space +including the last group . 6fthere is an asterisE in the left column, it should be separated from the end of the leftnumber b* a single space. Up to the #0 th character position should then be filled Fithspaces. Cumbers in the right column should begin at the #' st character position on theline and end Fith a neFline character.
Jest data Fill be chosen to ensure that no overlap can occur betFeen columns. 8fter shoFing each of the doubling steps, *our program should print the string! / Jhesolution is! / folloFed b* the product of the tFo numbers in g*ptian notation.
NeloF Fe shoF the steps corresponding to the multiplication of #%" b* 2(.
0ample .nput
I I I n n n n n n n n I I I I I I I n n
0ample :utput
I e I I I n n n n n n n n I I e I I I I I I n n n n n n I I I I I I n n n I I I I I I I I e I I I I n n n n n n I I I I I I n e I I I I I I I I n n Jhe solution is! I n n n n #
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 275/499
6nput ;ile! queen.inButput ;ile! queen.outource ;ile! queen.O>>><
Lueen Tour
Problem De"crip!ion
In c e"" ! e 3ueen i" ! e mo"! poKerful pice on ! e board, I! can a!!ackan% piece ! a! i" loca!ed ori1on!all% .er!icall% or diagonall% independen! of ! enumber of "3uare" form er, In ! e pic!ure belloK all ! e paKn" &P' are undera!!ack b% ! e 3ueen &L',
P P P
P EP
P
P P
Jhe ob ective of this problem is to place % queens in a chessboard in such a Fa* that none of the
queens are under attacE b* each other. our program Fill read the position of one queen, and output the
positions of the rest of the queens as shoFn beloF. Jhe are no restrictions on Fhere to place an* of each
input. Pust output one of the solutions. Left corner is +',' . ou can assume there is at least one valid
arrangement given the position of the first queen.
No!e":• Cote that brute force ma* not achieve a correct ansFer in a reasonable time.
ou should use the EnoFledge about the movement of the queen to limit thesearch. our solution should attain a correct ansFer in a reasonable time.
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 276/499
Sample Inpu!
1 2 Sample Ou!pu!
1 22 3 4 1
3:
:4
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 277/499
Input F&($ !&,$ (?.&nOutput F&($ !&,$ (?.+ut
S+u#"$ F&($ !&,$ (?.Q
On ! e SideKalk
Problem #escription
4onsider an arra* of floor tiles covering a sideFalE. ver* floor tile is numberedfrom 0 to C in ascending order. C is a positive nonGzero integer smaller than #0.
Jhere are children pla*ing on the sideFalE. 4hildren start to pla* at tile number 0.4hildren move forFard in steps of either one or tFo tiles. Jhere are no bacEFardmoves alloFed. 8ll children continue to move until the* reach tile C, Fhere the* stopand Fait for the rest of the children to arrive.
Jhe path folloFed b* a child ma* be represented b* a sequence of tile numbers,resembling the tiles the child stopped at. Iiven C, *our program Fill calculate thenumber of possible paths a child folloFed to reach tile C.
Jhe input file consists of a series of integers, one number per line. ach numberis a neF value for C for Fhich *our program Fill output the correct ansFer, as shoFnbeloF.
0ample .nput'"(%
0ample :utput
'"2'"#
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 278/499
.C:- Challenge Programming Contest-arch 'LJ &VVL
.ntermediate #ivision
Input F&($ (& $.&nOutput F&($ (& $.+ut
S+u#"$ F&($ (& $.Q
(o n ConKa% " +ame of $ife
Problem #escription
T $ G*'$ + L& $ *! &n)$nt$, 5- H+ n C+n *-. T $ @*'$ &! p(*-$, +n * &$(, + "$((!6$*" + &" *! $&@ t n$&@ 5+#! *,0*"$nt "$((!%. A "$(( &! $&t $# +""up&$, 5- *n +#@*nn+t. T $ #u($! +# ,$#&)&n@ * @$n$#*t&+n #+' t $ p#$)&+u! +n$ *#$ t $!$
#eath(
I *n +""up&$, "$(( *! <61646 6:6 6 +# +""up&$, n$&@ 5+#!6 t $ +#@*n&!' ,&$!(+n$(&n$!!a 4 t #u + +)$#"#+ ,&n@%.
0urvival(I *n +""up&$, "$(( *! t + +# t #$$ n$&@ 5+#!6 t $ +#@*n&!' !u#)&)$! t+ t $ n$ t
@$n$#*t&+n.
Birth(I *n un+""up&$, "$(( *! $ *"t(- t #$$ +""up&$, n$&@ 5+#!6 &t 5$"+'$! +""up&$,.
Y+u# p#+@#*' &! t+ !&'u(*t$ t $ @*'$ + (& $ +n * 1 1 @#&, +# * @&)$n nu'5@$n$#*t&+n!6 u!&n@ *n &nput @#&, *! @$n$#*t&+n <. T $ &nput &($ &(( "+n!&!t + t $ nu'5$# +@$n$#*t&+n! t+ 5$ ,&!p(*-$, *n, * (&!t + "++#,&n*t$! +# +#@*n&!'! &n @$n$#*t"++#,&n*t$! &(( 5$ + t $ +#' - $#$ &! t $ #+ *n, - &! t $ "+(u'n. T $ #*n@$ +# *n,- &(( 5$ #+' < t+ 14. T $ upp$#>($ t "+#n$# &! <6<%. Y+u '*- *!!u'$ p#+p$# "++#,&n*t$! &&nput.
Y+u# p#+@#*' 'u!t +utput * @#&, +# $*" @$n$# .t&+n &n"(u,&n@ @$n$#*t&+n < 5- * (&n$ +# t $ n*'$ + t $ @$n$#*t&+n6 *! ! + n 5$(+ . An $'pt- "$(( &(( 5$ #$p#$!$nt$, t $ +utput 5- > 6 *n, * (&)&n@ "$(( &(( 5$ #$p#$!$nt$, 5- .
S$$ !*'p($ &nput *n, +utput +n t $ n$ t p*@$.
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 279/499
0ample .nput
4: <: 1: 2: 3 4 4
0ample :utput
9eneration K>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>; >>>>>>>>>>;;; X----------->>>>; >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>G$n$#*t&+n 1>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>;;; >>>>>>>>>>>>;;;; >>>>>>>>>>>;;; >>>>>>>>>>>
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 280/499
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>G$n$#*t&+n 2>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>; >>>>>>>>>>>>>; >>; >>>>>>>>>>; >>>; >>>>>>>>>>>; >>; >>>>>>>>>>>>; >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>G$n$#*t&+n 3>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>; >; >>>>>>>>>>>;; >;;; >>>>>>>>>>; >; >>>>>>>>>>>
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 281/499
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>G$n$#*t&+n 4>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>;; >; >>>>>>>>>>>;; >; >>>>>>>>>>>;; >; >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 282/499
6nput ;ile! galac.inButput ;ile! galac.outource ;ile! galac.O>>><
+alac!ic Impor!
Problem De"crip!ion
K&t t $ &nt#+,u"t&+n + t $ n$ T #u!t+ ++' @&@*,&'$n!&+n*( ,#&)$#6 &t *! 5$"+'$ p+!!&5($ +#
J-p$#C+''+,&t&$!6 t $ &'p+#tb$ p+#t "+n@(+'$#*t$ #+' C &"*@+6 t+ 5$@&n t#*,&n@ &t $)$n t $ '+!t #$
@*(* &$! &n t $ un&)$#!$. J-p$#C+''+,&t&$! *nt! t+ &'p+#t @++,! #+' !+'$ + t $ @*(* &$! &n t $ P(u#*(
!$"t+#. P(*n$t! &t &n t $!$ @*(* &$! $ p+#t )*(u*5($ p#+,u"t! *n, #* '*t$#&*(! (&?$ )*"uu!$*(6 t#*n!p*#$
*(u'&n&u'6 ,&@#*p &t$ *n, u*ntu' !t$$(. P#$(&'&n*#- #$p+#t! *)$ #$)$*($, t $ +((+ &n@ *"t!
/ +ac% &ala y contains at least one and at most '6 planets. +ac% planet 0it%ina &ala y is identified by a uni1ue letter from 2 to 3.
/ +ac% planet specializes in t%e production and e port of one &ood. -ifferent planets 0it%in t%e same &ala y e port disfferent &oods.
; Some pairs of planets are connected by hyperspace shippin# lines, f planets A and $ are connected, they cantrade #oods freely f planet C is connected to $ but not to A, then A and C can still trade #oods !ith eachother throu#h $, but $ keeps < = of the shipment as a shippin# fee ("hus A only recei'es >< = of !hat C
shipped, and C recei'es only >< = of !hat A shipped ) n #eneral, any t!o planets can trade #oods as lon# asthey are connected by some set of shippin# lines, but each intermediate planet alon# the shippin# route keeps< = of !hat it shipped (!hich is not necessarily e?ual to <= of the ori#inal shipment)
; At least one planet in each #ala&y is !illin# to open a "hrusto@oom shippin# line to Earth A "hrusto@oom lineis the same as any other shippin# line !ithin the #ala&y, as far as business is concerned For e&le, if planet
opens a "hrusto@oom line to Earth, then the Earth can trade #oods freely !ith , or it can trade #oods !ithany planet connected to , subect to usual shippin# fees
A*per4ommodities has assigned a relative value +a positive real numberless than '0 to each planet:s chief e>port. Jhe higher the number, the morevaluable the product. @ore valuable products can be resold Fith a higher profitmargin in domestic marEets. Jhe problem is to determine Fhich planet has themost valuable e>port Fhen shipping fees are taEen into account.
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 283/499
Jhe input consists of one or more gala>* descriptions. ach gala>* description begins Fith aline containing an integer C Fhich specifies the number of planets in the gala>*. Jhe ne>t 4 linescontain descriptions of each planet, Fhich consist of!
'. Jhe letter use to represent the planet.2. 8 space". Jhe relative value of the planet:s e>port, in the form d.dd.#. 8 space&. 8 string containing letters andQor character a letter indicates a shipping line to that planet, and a R
indicates a Fillingness to open a JhrustoSoom shipping line to arth.
;or each gala>* description, output a single line Fhich reads /6mport from 71 Fhere 7 is theletter of the planet Fith the most valuable e>port, once shipping fees have been taEen into account. +6fmore than one planet have the same most valuable e>port value then output the planet Fhich isalphabeticall* first.
0ample .nput1J !& 1 ."E !&!1 .6= !&!1 6.C !&!1 .66 1&!! E=C>> !&!1 6.1!; 2&23 0.6 B&<* C "& M9E <&"$ CM "&!1 K <&$3 9E9 *&!B C &$2 E6K $&"" 0M0 3&21 ;K
0ample :utput9mport from J9mport from 69mport from 6
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 284/499
University of Puerto RicoMayaguez Campus
!"#$ "%allen&e * ,e%inner ivision
Sponsored by
AEIC and Lucent Technologies
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 285/499
Contents
1. Problem #1 Combinations2. Problem #2 Maya Calendar3. Problem #3 Palindrome4. Problem #4 Compression5. Problem #5 Sorting
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 286/499
Output F&#$ "+#n5&n +utS+u'$ F&L$ "+nn5&n.E;;;
Combina!ion"
Problem #escription
G&)$# *n *##*- + &nt$@$#! A *#, * !$p*#*t$ &nt$@$# N. ,$t$#'&n$ & t $#$ &! * !u5!$tt *t t $ !u' + &t! $($'$nt! &! $ u*( t+ N.
T $ &nput &(( *)$ t $ nu'5$# N &n * !$p*#*t$ (&n$6 +((+ $, 5- t $ $($'$nt! + A. $*" &n *!$p*#*t$ (&n$ T $ $n, + t $ *##*- &(( 5$ '*#?$, 5- t $ $n, + &($. T $ '* t u' !&8$ + t $ *##*-&! 1<<.
T $ &#!t (&n$ + * )*(&, +utput ! +u(, !t*t$ & t $ #$!u(t *! p+!&t&)$ +# n$@*t&)$ &.$. T&! *t ($*!t +n+ )*(&, "+'5&n*t&+nW. +# N+ )*(&, "+'5&n*t&+n *! "un,. %. I * )*(&, "+'5&n*t&+un, p#&nt t $ nu'5$#! t *t *#$ p*#t + &t
0ample .nput
1<23124
121:32:3:4122 :121<242<4
0ample :utput
T $#$ &! *t ($*!t +n$ )*(&" 8+'Z&#W" t+ (L
:3 :4 12 2 : 1
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 287/499
.C:- Challenge Programming Contest-arch'LJ &VVL
Beginner #ivision
Input F&($ '*-*.&nOutput F&($ '*-*.+ut
S+u#"$ F&($ '*-*.Q
Ma%a Calendar
Problem Description
During his last sabbatical, professor M.A .Ya made Surprising discovery about oldMaya calendar. From and old knotted message, professor discover that the Maya civilizationused a 365 .day long year, called Haab , which has 19 months. Each of the first 18 monthswas 20 days long , and the names of the months were pop no , zip , zotz ,
tzec , xul , yoxkin , mol , chen yax , zac ceh mac , kannin, muan, pax , koyab, cumhu. Instead of having names , the days in themonths were denoted by numbers starting , from 0 to 19. The last month of Haab wascalled uayet and had 5 days denoted by numbers O, 1, 2, 3, The Maya believed that thismonth was unlucky, the courtof justice was not in session, the trade stopped, people did noteven sweep the floor.
For religious purposes, the Maya used another calendar in which the yearwas called Tzolkin (holly year). The year was divided into:thirteen periods,each 20 days long. Each day was denoted by a pair consisting of a number and
the name of the day. They used 20 names: imix , ik , akbal , kan , chicchan, cimi,manik, lamat, muluk , ok, chuen, eb , ben, ix, mem, cibcaban eznab, canac , ahau , and 13 numbers; both in cycles.
Notice t*at eac* da *as an ambi description. For e3ample4 at t*e be%innin%+ t $ -$*# t $ ,*-! $#$ ,$!"#&5$, *! +((+ !
1 imix, 2 ik, 3 akbal, 4 kan, 5 chicchan, 6 cimi, 7
manik , 8 lamat , 9 muluk , 10 ok , 11 chuen, 12 eb, 13 ben,1 ix, 2, mem, 3 cib, 4 caban , 5 eznab , 6 canac , 7 ahau ,andagain in the next period 8 imix D ik , 10 akbal ...
Years (both Haab and Tzolkin) were denoted by numbers O, 1……….thenu'5$# < *! t $ 5$@&nn&n@ + t $ +#(,. T u! t $ &#!t ,*- *!
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 288/499
5aab: O, pop Tzolkin: 1 imixO
Help professor M.A. Ya and write a program for him to convert the dates from the Haab calendar to theTzolkin calendar.
Sample Input
The date in Haab is given in the following format:
NurnberOfTheDay. Month Year:
The first line in the file contains the number of the input dates in the file. The next n lines contain n dates in theHaab calendar format, each in a separate line. The year is smaller than 5000.
110. zac 0
Sample Output
The date in Tzolkin should be in the following format:
Number NameOfDay Year The first line of the output file contains the number of the output dates. In the next n lines, there are dates inthe Tzoikin calendar format, in the order corresponding to the input dates.
13 chuen 0
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 289/499
Input File: pall.inOutput File: pall.out
Source File: pali.[xxx]
Palindrome De!ec!ion 0"ing Recur"ion
Problem DescriptionThe goal of this problem is to write a program that will accept a string with a maximum length
of 50 and determine if it is a palindrome. A palindrome is a word or string which is spelled the sameforwards and backwards. The function you create to solve this problem must be recursive.
Your solution to the palindrome problem must have only one call in the main() function and itmust call itself successively thereafter, until an answer is returned. Furthermore your entire programshould only take into account numbers and letters when determining if a string is a palindrome, but itshould print out the entire string as entered when displaying the answer. The program should not becase sensitive; 'A' and 'a' are equivalent.
Sample InputA data file with several strings, one string per tine, each string no longer than 50 characters.
Abba 8 ab’BAAbbcb Bb
Sample Output
A file displaying the string and whether or not the string is considered a palindrome.
"Abba 8 ab’BA" is a palindrome."Abbcb Bb" is not a palindrome.
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 290/499
University of Puerto RicoMayaguez Campus
!"#$ "%allen&e 5*
Beginner Division
Sponsored by
AEIC and Lucent Technologies
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 291/499
.C:- Challenge Programming ContestMarch 28, 1998
Beginner DivisionInput File: comp.in
Output File: comp.outSource File: comp.[xxx]
Compre""ion
Problem Description
In Telephony applications, we often receive messages which contain a stream of digits to bemanipulated, stored, or otherwise passed to other applications. In a particular example, we canreceive up to 15 digits, with values ranging from 0 to 9, inclusive. These digits arrive to our system ina stream of bytes characters ,one digit per byte. Our system needs to store these digits into anexisting structure; however, we only have 8 bytes of free space available. Write a program thatcompresses up to 15 digits into an array of 8 bytes. The compressed array should contain 2 digits perbyte. The following is a memory layout of the arrays.
Note that empty slots in the compressed structure contain the hexadecimal value f. This helps determine the endof the stored digits.
Input
The input file contains rows of digits separated a by spaces.
5551212121
Output
The output of your program should contain:
· The number of digits in the row.
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 292/499
• The digits on the uncompressed stream represented as a two digit Hexadecimal value up to the number of digits in the row.• The entire compressed structure (including empty slots)• S$p*#*t$ $*" !t#$*' +utput * 5(*n? (&n$
705050501020102551512f2ffffffff
301020121 f 1 ffffffffffff
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 293/499
ICOM C allenge Programming Con!e"!Marc 4 B
#eginner Di.i"ion
6nput ;ile! sort.inButput ;ile! sort.outource ;ile! sort.O>>><
Sor!ing Problem
Problem De"crip!ion
Iiven tFo arra*s 8 and N of sorted positive integers!
• ver* element in the arra* is greater or equal to 0• Cumber of elements in each arra* = 2&• Bne or more occurred of the same number arra*s.
4ode a program that produce a sorted list of elements after combining the elements of arra* 8 and N Fithout using a thirdarra* or list to perform the sorting and Fithout repeating numbers in the output.
Sample Inpu!
• JFo lines of positive integers! first line corresponds to arra* 8, second one corresponds to arra* N.• ach arra* element is separated b* space.
' # & ( % "2 #& &( $& $( (%0 # ( % '' '& 2' 2( "# #& &(
Sample Ou!pu!
orted list of elements
0 ' # & ( % '' '& 2' 2( "2 "# #& &( $& $( (%
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 294/499
University of Puerto RicoMayaguez Campus
!"#$ "%allen&e 5*
Expert Division
Sponsored by
AEIC and Lucent Technologies
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 295/499
ICOM Challenge 1997 Programming ContestMarch 15, 1997
$OP$RT #./.0.:N
Problem: 5TM$ Table"
Write a program that given an HTML source code displays the table included in the document. The displayshould include borders and the table's content.
HTML (HyperText Markup Language) is a markup language which consists of tags embedded in the text of adocument. The browser reading the document interprets these markup tags to help format the document forsubsequent display to a reader.
• · A table is created using the <TABLE> markup tag. The simplest table consists of a single data cell.• ·BORDER
• Specifies that a border is to be placed around the table cells. The width of the border is optionally specifiedwith BORDER--n.
• The markup <TD> defines the start and </TD> defines the termination of a table data cell.• To form a table of many rows, the markup tag <TR> is inserted where each new row in the table
starts. The termination tag for the row is </TR>.• The tag <TH> may be used instead of <TD> if the cell is a header to a column of cells.
Example:
T $ !+u#"$ "+,$ +# * t*5($ (++?! (&?$
fTABLE BORDERXIZfTRZfTJZN*'$fbTJZfTJZT$($p +n$ Nu'5$#fbTJZ fbTRZfTRZfTDZHu*nfbTDZfTDZ > fbTDZfbTRZfTRZfTDZM*#&*fbTDZ fTDZ > fbTDZfbTRZfbTABLEZ
T $ t*5($ &(( (++? (&?$
Name Telephone NumberHu*n >M*#&* >
T $ !+u#"$ "+,$ +# t &! p#+@#*' &! $ *'p($. t'(.
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 296/499
roblem- AEIC Words
Design a word processor that reads a file and allows the following commands:
col N - sets the number of columns to display data.
replace <word>-<newword>- replaces all occurrences of <word>with <newword>.Erase <word>-erases all occurrences of <word>.save <filename>- save changes to disk. If no argument is
given, changes will be saved to the same input file.load <filename>- opens the file.Quit- exits tke program
Note: By default the word processor will display the data in ! columns" Itis not case sensiti#e" If a word e$ceeds the limit of columns it is mo#ed to
the ne$t line" %he commands are not case sensiti#e"
%he input file will be called filename"t$t"
Sample run:
................... FILENAME.TXT .......................................This book provides a comprehensive and unified introduction to operating systems. The book emphasizes bothfundamental principles and design .issues in contemporary systems. Thus it is both a basic reference and up-to-date survey of the state of the art.
cmd:> load filename.txt
................... FILENAME.TXT ........................................This book provides a comprehensive and unified introduction to operating systems. The book emphasizes bothfundamental principles and design issues in contemporary systems. Thus it is both a basic reference and up-to-date survey of the state of the art.
cmd:> col 67
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 297/499
................... FILENAME.TXT ........................................This book provides a dull and unified introduction to operating systems. The book emphasizes both fundamentalprinciples and design issues in contemporary systems. Thus it is both a basic reference and up-to-date survey ofthe state of the art.
cmd:> replace comprehensive dull
................... FI[.ENAME.TXT .......................................This provides a dull and unified introduction to operating systems. The emphasizes both fundamental principlesand design issues in contemporary systems. Thus it is both a basic reference and up-to-date survey of the state ofthe art.
crnd:> erase book
.............................. OS.TXT ....................................This provides a dull and unified introduction to operating systems. The emphasizes both fundamental principlesand design issues in contemporary systems. Thus it is both a basic reference and up-to-date survey of the state ofthe art.
crud:> save oS.txt
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 298/499
7roblem : Na.iga!ion of a Simple Ma1e
Jhe goal of the program is given a start location Fithin the maze, to find the e>it point andprint out the optimal solution. Nefore Fe start letHs looE at a simple maze and transform it to atree structure.
Te have labeled each position Fithin the maze Fith numeric labels to aid the
transformation to a tree structure. Jhe transformafion *ields!
earching such a maze reduces to vieFing the maze as a tree structure and using an
appropriate algorithm. uch an algorithm is the preorder search. Jhe preorder searchDtravelsD around a tree structure, alFa*s taEing the left branch if possible, and DlooEsD at eachnode as it is encountered. 6n our situation, Fe are looEing for the BUJ node. Iiven the ma ebeloFM Frite a program to implement the preorder algorithm +hint! itHs recursive to find thesolution to the maze.
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 299/499
our program should prompt for starting coordinates, search the maze, then print thesolution. 8 sample run might looE liEe this!
THE AMAZING MAZE PROGRAM
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 300/499
Jhe solution to the maze is!
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 301/499
University of Puerto RicoMayaguez Campus
!"#$ "%allen&e 5*
Intermediate Division
Sponsored by
AEIC and Lucent Technologies
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 302/499
.NT$R-$#.AT$ #./.0.:N
Problem: 6ord Morp ing
In t &! p#+5($' -+u &(( t#*n! +#' +#,! &nt+ +t $# +#,!6 +n$ " *#*"t$# *t * t&'$.
PROBLEM STATEMENT
1. 1>'+#p ! T $ !$t + 1>'+#p ! + * +#, &! t $ !$t + +#,! &n &" +n$ ($tt$# &! " *n@$,*n, + ($tt$#! *#$ #$*##*n@$,. K#&t$ t $ p#+@#*' $ &" p#&nt! * (&!t +! *(( t $ 1>'+#p+#,. Y+u &(( 5$ p#+)&,$, &t * ,&"t+n*#- &($ n*'$, KORDS + *""$pt*5($ +#,! &n*(p *5$t&"*( +#,$#6 +n$ +#, t+ * (&n$.
2. L*,,$#@#*'! A (*,,$#@#*'!&! * " *&n + 1>'+#p ! &" t#*n! +#' * !t*t&n@ +#, &nt+ *n$n,&n@ +#,. F+# $ *'p($6 t $ ! +#t$!t (*,,$#@#*' " *n@&n@ t $ +#, [($*,\ &nt+ t $+#, [@+(,\ &! ($*, (+*, @+*, @+(,. K#&t$ * p#+@#*' &" &n,! *n, p#&nt! * (*,,$#@#+ ! +#t$!t ($n@t 5$t $$n t $ !upp(&$, !t*#t&n@ *n, $n,&n@ +#,! u!&n@ t $ !*'$ !upp(&,&"t&+n*#-%.
TECJNICAL CONSTRAINS
T $ ,&"t&+n*#- &($ &! ,&"t.&n.
SAMPLE RUNS
P*#t 1
T $ 1>'+#p ! + TIMES *#$T&'$# t&'$, t&#$! t&($! t&,$! t*'$! (&'$! ,&'$!
P*#t 2
J$#$ *#$ !+'$ ! +#t$!t !+(ut&+n! -+u "*n u!$ t+ t$!t -+u# p#+@#*'
LOVE t+ JATE (+)$ (+n$ (*n$ (*t$ *t$BRAIN t+ TJIN 5#*&n t#*&n t#*&t t#*"t t#*"? t#&"? t &"? t &n? KJITE t+ BLAC &t$ &n$ ! &n$ !p&n$ !p&"$ !(&"$ !(&"? !(*"? 5(*"?
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 303/499
7roblem! Cr%p!ari! me!ic
Write a program that solves a cryptarithmetic problem. In cryptarithmetic problems, letters stand for digits andthe aim is to find a substitution of digits for letter such that the resulting sum is arithmetically correct.
TECHNICAL CONSTRAINS:
1. Each letter must stand for a different digit.SAMPLE RUNS:
FORTY + TEN
+ TEN-----------SIXTY
olution!
29786 850850
---------- 31486
F=20=9R=7T=8Y=6E=5N=0
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 304/499
7roblem : Na.iga!ion of a Simple Ma1e
Jhe goal of the program is given a start location Fithin the maze, to find the e>it point andprint out the optimal solution. Nefore Fe start letHs looE at a simple maze and transform it to atree structure.
Te have labeled each position Fithin the maze Fith numeric labels to aid thetransformation to a tree structure. Jhe transformafion *ields!
earching such a maze reduces to vieFing the maze as a tree structure and using anappropriate algorithm. uch an algorithm is the preorder search. Jhe preorder searchDtravelsD around a tree structure, alFa*s taEing the left branch if possible, and DlooEsD at eachnode as it is encountered. 6n our situation, Fe are looEing for the BUJ node. Iiven the ma ebeloFM Frite a program to implement the preorder algorithm +hint! itHs recursive to find thesolution to the maze.
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 305/499
our program should prompt for starting coordinates, search the maze, then print thesolution. 8 sample run might looE liEe this!
THE AMAZING MAZE PROGRAM
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 306/499
Jhe solution to the maze is!
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 307/499
7roblem : Da!e!ime
K#&t$ * p#+@#*' t *t #$*,! * !t#&n@ #$p#$!$nt&n@ * ,*t$t&'$6 &n t $ ----'',, ''!!. K $#$ ---- &! t $ -$*#6 '' &! t $ '+nt 6 ,, &! t $ ,*-6 &! t $ +u#)*(&, )*(u$! *#$ << t+ 24%6 '' *#$ t $ '&nut$! << = :<%6 *n, !! *#$ t $ !$"+n,! << = :<%. T
p#+@#*' *(!+ #$*,! * !t#&n@ #$p#$!$nt&n@ * t&'$ &n t $ +((+ &n@ +#'*t ''!!. T $ p#+@
'u!t t $n !u5t#*"t t $ t&'$ #+' t $ ,*t$t&'$ *n, ,&!p(*- t $ #$!u(t. Y+u# p#+@#*' 'u!t *n,($($*p -$*#!. A -$*# &! * ($*p -$*# & &t &! ,&)&!&5($ 5- 46 5ut n+t 5- * 1<<6 +# & t $ -$*# 5- 4<<.
TECJNICAL CONSTRAINS
1. Input *n, +utput 'u!t 5$ ,+n$ &nt$#*"t&)$(-.2. T $ &nput &! +n$ !t#&n@ + ($n@t 14 #$p#$!$nt&n@ t $ ,*t$t&'$6 *n, +n$
!t#&n@ + ($n@t : #$p#$!$nt&n@ * t&'$. Y+u# p#+@#*' ! +u(, )*(&,*t$ t *tt $ u!$# $nt$#$, )*(&, )*(u$! *n, ,&!p(*- *n, $##+# [In)*(&, ,*t$t&'$.\ O#[In)*(&, t&'$.\ I n+t.
SAMPLE RUN
,*t$t&'$ 1 <3111<4<33t&'$ 233<1#$!u(t 1 <3111<11
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 308/499
ICOM C *(($n@$ 1P#+@#*''&n@ C+nt$!tM*#" 1 6 1
B$9.NN$R #./.0.:N
P#+5($' O#,$#$, F#*"t&+n!
C+n!&,$# t $ !$t + *(( #$,u"$, #*t&+n*( nu'5$#! 5$t $$n < *n, 1 &n"(u!&)$ &t ,$n+'&n*t+#! +# $ u*( t+ N.
J$#$ &! t $ !$t $n NX
K#&t$ * p#+@#*' t *t6 @&)$n *n &nt$@$# N 5$t $$n 1 *n, 1<< &n"(u!&)$6 p#&nt! t $ #*"t&&n"#$*!&n@ '*@n&tu,$. Y+u ! +u(, *(!+ p#&nt t $ t+t*( nu'5$# + #*"t&+n!. P#&nt * t*5 * t$#*"t&+n !+ t $- ,+ndt #un t++ *# + t $ !"#$$n ,u#&n@ 0u,@&n@.
TECJNICAL CONSTRAINS
1. P#+@#*'! 'u!t #$0$"t &nput! $#$ N &! ($!! t *t 1 +# @#$*t$# t *n 1<<.
SAMPLE RUN
Ent$# t $ '* &'u' ,$n+'&n*t+#
<b1 1b 1b4 1b3 2b 1b2 3b 2b3 3b4 4b 1b1
T $#$ $#$ 11 #*"t&+n!.
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 309/499
7roblem! Magic Number
K#&t$ * p#+@#*' t *t "#$*t$! * t +>,&'$n!&+n*( *##*- nen% &t nu'5$#! 1 t #+u@ n2. T $ nu'5$# n&! $nt$#$, 5- "+''*n, (&n$. T $ nu'5$#! *#$ p(*"$, &n !u" * *- t *t &t! "+(u'n !u'!6 #+ !u'!*n, ,&*@+n*( !u'! *#$ $ u*(. T $ nu'5$# n 'u!t 5$ +,,.
TECJNICAL CONSTRAINS
1. T $ p#+@#*' 'u!t #$0$"t &nput! $#$ n &! $)$n.
SAMPLE RUN
Ent$# '*@&" nu'5$# n 3
3 &! t $ ,&'$n!&+n + t $ nen '*t#& *n, &! *n +,, nu'5$#.
1 :34 2
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 310/499
7roblem! A Talk Packe! Sniffer
Sutano's conversation in "talk" was recorded in a log file by the System Administrator. The log files consistsof a series of integers and separated by white spaces or carriage returns. The file has the following format:
Message-type Data- type Datasize Data...
Message type: 0 for received message 1 for sent message
Datatype: 0 indicates that the data field consists of ASCII values 1 indicates that the data field consists of integers
Datasize: Nmber of integers to be read.
Data: the message in the form of integers
Given the log file, decode the message and write on the screen with the following format:
(sent): messagel(received) :message2.
7roblem! Dic!ionar%
Given a text input file build a database that contains the words used in the text file. You can't repeat wordsand the output file must be in alphabetical order.
Source file = Dict.txt
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 311/499
University of Puerto RicoMayaguez Campus
!"#$ "%allen&e 5*7
Expert Division
Sponsored by
AEIC and Lucent Technologies
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 312/499
ICOM Challenge 1995Programming Contest
March 11, 1995
$OP$RT #./.0.:N
ProblemB, Da!e!ime
0ource File Name $# .4OOO
Problem(K#&t$ * p#+@#*' t *t #$*,! * !t#&n@ #$p#$!$nt&n@ * ,*t$t&'$6 In
--@-'',, ''!!6 $#$ YYY@ I! t $ -$*#6 '' &! t $ '+nt 6 ,, &! t $ ,*-6 &! t $ +u# u*(&,)*(u$! *#$ t 24%6 '' *#$ t $ '&nut$! > : %6 *n, !! *#$ t $ !$"+n,! m > : %. T $ p#+@#*' *#$*,! * !t#&n@ #$p#$!$nt&n@ * t&'$ &n t $ +((+ &n@ +#'*t ''!!. T $ p#+@#*' 'u!t t $n !ut $ t&'$ #+' t $ ,*t$t&'$ *n, ,&!p(*- t $ #$!u(t. Y+u# p#+@#*' 'u!t *n,($ ($*p -$*#!. A -$*#
($*p -$*# & &t &! ,&)&!&5($ 5- 46 Gu& 6$t 5 * & 6 +# & t $ -$*# &! ,&)&!&D&$ 5- 4&&Input *n, +utput 'u!t 5$ ,+n$ &nt$#*"t&)$(-.
Input:On$ !t#&n@ + ($n@t 14 #$p#$!$nt&n@ t $ ,*t$t&'$6 *n, +n$ !t#&n@ + ($n@t : #$p#$!$nt&n@ * t&'$. Y+u# p
)*(&,*t$ t *t t $ u!$# $nt$#$, )*(&, )*(u$! *n, ,&!p(*- *n, $##+# &n)*(&, ,*t$t&'$. +# &n)*(&, t&'$. & n+t.
E *'p($
.nput,*t$t&'$ 3>11t&'$ 233 1
Butput!result! '))&0"'''0'%
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 313/499
T.TU!: #$! PR:B!$-A
7roblem 2. C ri"!ma" Tree
ource ;ile Came! 892.VVV
P#+5($' K#&t$ * p#+@#*' t+ ,#* *n, ,&!p(*- * C #&!t'*! t#$$ +n t $ !"#$$n. N+t$ T &! p#+@#*' &(( 5$ 0u,@$, *""+#,&n@ t+ + $(*5+#*t$ *n, L&)$(- -+u
*n, n+t &n t $ t&'$ &t t++?. B$ "#$*t&)$6 &'p#$!! t $ 0u,@$!. T&'$ &(( 5$ u!$, +n"*!$ + * t&$. O "+u#!$6 t $ #$!t + t $ p#+5($'! &(( 5$ 0u,@$, 5- t&'$6 !+ & -+ut++ 'u" t&'$ +n t &! +n$6 -+u &(( *)$ ($!! t&'$ +# t $ +t $#!.
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 314/499
Pa"cal !o C Mini)6 ile) Con.er!er
0ource File Name( A#=4OOO.nput File Name( A#=4Pas:utput File Name( A#=4C
#e7ine( The ?hile statement in the Pascal language has the 7ollo?ing 7ormat(
?hile boolean-expression do program-statement;
e54?hile n M &K do
n( n^5`
The ?hile statement in the C language has the 7ollo?ing 7ormat(
?hile (boolean expression) program-statement;
e54?hile 2n M &K6
n( n^5`
The assignment statement in Pascal has the 7orm
variable := expression;
?here e5pression may be a constantJ another variableJ or a7ormula to be evaluated4
.n CJ the assignment statement has the 7ollo?ing 7orm(
variable = expression ;
The begin and end statements .n Pascal translate to open 2 6 and close 2 6 brac3ets in CThe end in Pascal is 7ollo?ed by a semicolon 2 ` 6J but the close brac3et in C is not4
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 315/499
ICOM Challenge 1995Programming Contest
March 11, 1995
T $ f6 Z6f>>6 Z> (+@&"*( +p$#*t+#! *#$ t $ !*'$ &n 5+t C *n, P*!"*(. T $!$ *#$ t $ +n(--+u# p#+@#*' n$$,! t+ !upp+#t. In +t $# +#,!6 t $ P*!"*( &($ 5++($*n $ p#$!!&+n! t *t p#+@#*' n$$,! t+ t#*n!(*t$ *#$6 +# $ *'p($ nfX1 6 "nt Z 6 "+unt ( ZX "+unt26 t f 2.
P#+5($'K#&t$ * P#+@#*' t+ t#*n!(*t$ )*(&, &($ !t*t$'$nt! &n P*!"*( t+ t $ C (*n@u*@
p#+@#*' &(( #$*, * P*!"*( &($ !t*t$'$nt #+' t $ &($ AD3.p*!6 *n, &(( #&t$ t $ $ u&u*(!t*t$'$nt &nt+ t $ &($ AD3.". Y+u# t#*n!(*t+# p#+@#*' 'u!t "+n!&,$# t $ "*!$ + *!!&@n'$nt !t*t$'$nt! &t &n t $ !&n@($ &($ !t*t$'$nt 5$@&n *n, $n,. Y+u ,+ n+t *U$ t+ +*5+ut n$!t$, &($ !t*t$'$nt!. Y+u ,+ n+t n$$, t+ +##- *5+ut *##*-! $&t $#. R! '$nt&+n$, *5-+u# p#+@#*' +n(- n$$,! t+ !upp+#t t $ f6 Z6 f>6 Z> &" *#$ t $ !*'$ &n 5+t C *n, P*!"*(.
S*'p($ InputbOutput
Input&($ ;Z. 1 ,+
5$@&nn >3a 0 Xn> a
$n,a
Output
&($ Z> I %mn>3a 0>n> a
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 316/499
ICOM C *(($n@$ 1P#+@#*''&n@ C+n
M*#" 116 1
Re"!auran! Da!aba"e
S+u#"$ F&($ N*'$ RD4.;;;
InputbOutput F&($ N*'$ RD4.DB
P#+5($'
T $ D$p*#t*'$nt+ ,$ Tu#&!'+ ,$ Pu$#t+ R&"+ *! &#$, -+u t+ #&t$ * p#+@#*' t *t &(( #$!t*u#*nt ,*t*5*!$ t *t t+u#&!t! "*n u!$ t+ ,$"&,$ $#$ t+ @+ +# ,&nn$#. T $ ,*t*5*!$ &(+((+ &n@ &n +#'*t&+n +n #$!t*u#*nt! n*'$6 *,,#$!!6 p +n$ nu'5$#6 t-p$ + #$!t*u#*nt C &It*(&*n6 Sp*n&! 6 $t". %6 *n, t $ t*((#&@ m L+ stars)
T $ p#+@#*' 'u!t ,&!p(*- * '$nu t *t *((+ ! t $ u!$# t+ p$# +#' t $ +((+ &n@ +p$#*t&+n!I% *,, * #$!t*u#*nt t+ t $ ,*t*5*!$2% ,$($t$ * #$!t*u#*nt #+' t $ ,*t*5*!$3% up,*t$ * #$!t*u#*nt ! ,*t*4% &n, * #$!t*u#*nt ITU t $ t-p$. I t $ u!$# *nt! C &n$!$ #$!t*u#*nt!6 @&u$ * (&!t + *(( C#$!t*u#*nt! &n t $ ,*t*5*!$.% $ &t t $ p#+@#*'
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 317/499
University of Puerto RicoMayaguez Campus
!"#$ "%allen&e 5*7
Intermediate Division
Sponsored by
AEIC and Lucent Technologies
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 318/499
.NT$R-$#.AT$ #./.0.:N
7roblem ' , +rea!e"! Common Di.i"or
S+u#"$ F&($ n*'$ ID1.D$ &n&t&+n
T $ @#$*t$!t "+''+n ,&)&!+# + t + &nt$@$#! * *n, 56 GCD *65% n+t 5+t + &" *#$ 8(*#@$!t p+!&t&)$ &nt$@$# t *t ,&)&,$! 5+t * *n, B.
T $ ($*!t "+''+n 'u(t&p($ + * *n, 56 LCM *65% &! t $ !'*(($!t n+nn$@*t&)$ &nt$@$# 'u(t&p($ + 5+t * *n, 5 *n, "*n 5$ "*("u(*t$, u!&n@.
LCM *6 5% X b*5b ______
GCD *6 5%
P#+5($'K#&t$ * p#+@#*' t *t #$*,! t + &nt$@$#!6 *n, ,&!p(*-! t $&# GCD *n, t $ LCM. Input
! *(( 5$ ,+n$ &nt$#*"t&)$(-.
S*'p($ Inputb Output
Input12:<1
OutputGCM X 1LCM X 13 :<
7roblem 2. Mea"uremen! and 0ni! Con.er"ion
S+u#"$ F&($ N*'$ ID2.
P#+5($'K#&t$ * '$nu>,#&)$n p#+@#*' t *t *((+ ! t $ u!$# t $ +((+ &n@ +pt&+n!
1% t+ "+n)$#t '$*!u#$'$nt! #+' '&nut$! t+ +u#!2% t+ "+n)$#t $$t t+ '$t$#! 1 ++t X <.3<4 '$t$#%3% t+ "+n)$#t #+' ,$@#$$! F* #$n $&t t+ ,$@#$$! C$(!&u! F X 1. C 32%.4% T+ $ &t t $ p#+@#*'
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 319/499
Problem 2, S!ack Manipula!ion
0ource 7ile name( .#=4555
P#+5($'K#&t$ * p#+@#*' t+ "+n)$#t *n $ p#$!!&+n &n &n & n+t*t&+n t+ p+!t & *n, p#$ & n
*n, +utput ! *(( 5$ ,+n$ &nt$#*"t&)$(-.
InputA !t#&n@ n+ (+n@$# t *n < " *#*"t$##$p#$!$nt&n@ t $ $ p#$!!&+n &n &n & n+t*t&
S*'p($ Input b Output
Input2 e 3 4%
OutputP+!t & n+t*t&+n 2 3 4 eP#$ & n+t*t&+n e 2 3 4
7roblem #. #inar% !o decimal oc!al and e9 con.er"ion
S+u#"$ F&($ N*'$ ID4. ;;;
P#+5($' K#&t$ * p#+@#*' t *t "+n)$#t! * !t#&n@ + 5&n*#- ,&@&t! <! *n, 1!% t+ &t! ,$"&'*(6$ *,$"&'*( #$p#$!$nt*t&+n. T $ '* &'u' nu'5$# + 5&n*#- ,&@&t! t*?$n *! &nput &! 24.
S*'p($ InputbOutput
Input <<11<1<1<<<11<1<
OutputJ$ *,$"&'*( 3 1AO"t*( 32432=ecimal: $*3*2
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 320/499
.C:N Challenge &VV
Problem B Pre.iou" Da!e
P#+5($' K #&t$ * p#+@#*' t+ ,$t$#'&n$ t $ ,*t$ + t $ p#$)&+u! ,*- +# *n- ,*t$ @&)$n 5- t $ u!$nu'5$# + ,*-! &n $*" '+nt &! *! +((+ !
H*n > 31 M*- > 31 S$pt. > 3<F$5. > 2 +# 2 e Hun$ > 3< O"t. > 31M*#" > 31 Hu(- > 31 N+). > 3<Ap#&( > 3< Au@. > 31 D$". = 31
eF$5#u*#- *! 2 ,*-! n+#'*((-6 $ "$pt &n ($*p -$*#! $n &t *! 2 ,*-!. A -$*# &! * ($*pt&t &! ,&)&!&5($ 5- 4<<.
Input
A !t#&n@ + ($n@t #$p#$!$nt&n@ * ,*t$ &n t $ +#' ----'',, $#$ --- &! t $ -$*#6 '' &! '+nt 6 *n, ,, &! t $ ,*-.
T $ &nput 'u!t 5$ )*(&,*t$, *n, t $ $##+# [In)*(&, D*t$\ 'u!t 5$ @&)$n & t $ ,*t$ $nt$#$)*(&,.
OutputA !t#&n@ + ($n@t #$p#$!$nt&n@ t $ p#$)&+u! ,*t$6 &n t $ +((+ &n@ +#'*t ----'',,
N+t$Input *n, +utput 'u!t 5$ ,+n$ &nt$#*"t&)$(-.
;ample: Input 1 <311Output 1 <31<
Input 1 :Output In)*(&, D*t$.
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 321/499
ICOM Challenge 1995Programming Contest
March 11, 1995
Problem 4, Di"!ance Midpoin! and Slope
S+u#"$ F&($ N*'$ BD2.;;;D$ &n&t&+n
D&!t*n"$ F+#'u(*T $ ,&!t*n"$ , P(6 P2% 5$t $$n *n- t + p+&nt! PI 16 Y(% *n, P2 26 Y2% &n *
p(*n$ &!
, P(6 P2% X ;( > 2%2 Y( > Y2%2
;( 2 Y( Y2H
2 2
S(+p$L$t I 5$ * (&n$ t *t &! n+t p*#*(($( t+ t $ - * &! *n, ($t P(&;(6
Y(% *n, P2 26 Y2% 5$ ,&!t&n"t p+&nt! +n I6 t $ !(+p$ ' + I &!Y2 > Y(
' >>2 > I
I I &! p*#*(($( t+ t $ - * &!6 t $n t $ !(+p$ &! n+t ,$ &n$,.
ProblemK#&t$ * p#+@#*' t *t t*?$! t + p+&nt! PW u!$#6 *n, &n, t $
*n, P2 #+' *
*% ,&!t*n"$ 5$t $$n t $ p+&nt!5% t $ '&,p+&nt + t $ (&n$ !$@'$nt #+' PI t+ P2"% t $ !(+p$ + t $ (&n$ t *t p*!!$! t #+u@ PI *n, P2. I n+t ,$ &n$,6 &n,&"*t$ !+.
Input *n, +utput 'u!t 5$ ,+n$ &nt$#*"t&)$(-.
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 322/499
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 323/499
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 324/499
S*'p($ InputbOutput
Input
;( X Y( X3 2 X > Y2X
Output
d2P iJ P'6 &=4KK'&,p+&nt X >I.<<6 . <% !(+p$ X ><.42
M&,p+&nt F+#'u(*T $ '&,p+&nt + t $ (&n$ !$@'$nt #+' P 6 -% t+ P2 6 -%
&!:
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 325/499
ICOM Challenge 1995Programming Contest
March 11, 1995
7roblem ". C ange
S+u#"$ F&($ N*'$ BD3.;;;
P#+5($'K#&t$ * p#+@#*' t *t6 @&)$n *(( *'+unt + '+n$- *! &nput6 &(( #$tu#n t $ nu'5$# + u*#t,&'p. !6 n&"?$(!6 *n, p$nn&$! t *t *,, up t+ t $ *'+unt $nt$#$, u!&n@ t $ '&n&'u' nu'5$#+ "+&n!.Input *n, +utput ! *(( 5$ ,+n$ &nt$#*"t&)$(-.
0ample .nput<:utput(
Input 2.1
Output
D 1 N 1P 2
Problem Q, Te9! Edi!ing
S+u#"$ F&($ N*'$ BD4.;;;
P#+5($'
K#&t$ * p#+@#*' t *t p$#'&t! t $ &nput + * n*'$ "+n!&!t&n@ + * &#!t n*'$6 * '&,,($ n*&n&t&*(6 *n, * (*!t n*'$6 &n t *t +#,$# 6 *n, t $n p#&nt! t $ (*!t n*'$6 +((+ $, 5- * "+''* 6 *n,t $n&#!t *n, '&,,($ &n&t&*(6 $*" +((+ $, 5- * p$#&+,. T $&nput *n, +utput ! *(( 5$ ,+n$ &nt$#*"t&
S*'p($ InputbOutput
T $ &nput [ H+ n J. D+$ [ ! +u(, p#+,u"$ [ D+$6 H. J. [
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 326/499
University of Puerto Rico
Mayaguez Campus
!"#$ "%allen&e 5*8
Expert Division
Sponsored by
AEIC and Lucent Technologies
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 327/499
$OP$RT #./.0.:N
7roblem 6. Memor% Managemen!
S+u#"$ F&($ N*'$ ED I.;;;
#e7inition(T $ +p$#*t&n@ !-!t$ ' *n, *#, *#$ ,&)&,$ )&#tu*( '$ '+#- &nt+ p*@$! + &,$nt&"
!&8$ *n, ,&)&,$ #$*( '$ '+#- &nt+ p *@$ #*'$!. Du#&n@ t $ "+u#!$ + $ $"ut&n@ * p#+@#*'6@$n$#*t$! * !$ u$n"$ + )&#tu*( p*@$ #$ $#$n"$! "*(($, t $ #$ $#$n"$ !t#&n@
R X # 1# 2 # ?
I t $ p*@$ # 1 5$&n@ #$ $#$n"$, &! #$!&,$nt &n * p*@$ #*'$6 t $ #$ $#$n"$n+#'*((-. Ot $# &!$6 & t $ p*@$ &! n+t &n '$ '+#-6 * p*@$ *u(t &nt$##upt +""ut &! *pp$n!6 t $ CPU !" $,u($# "+p&$! t $ p*@$ &nt+ '$'+#-. I t $#$ &! n+ p*@$*)*&(*5($ #$$% In '$ '+#-6 t $ CPU !" $,u($# t*?$! * p*@$ #+' '$ '+#- *n, "+p&$
t+ * ,&!?. It t $n p(*"$! t $ n$ p*@$ &n * p*@$ #*'$. T &! &! "*(($, ! *pp&[email protected]#+5($'
Up+n $ $"ut&+n + * p#+@#*'6 t $ +((+ &n@ #$ $#$n"$ !t#&n@ &! @R X 2 2 22 2 2 22 33 33% n3 333 3 322
A!!u'$ nXI<6 &" '$*n! t *t t $ !u5!t#&n@ &t &n p*#$nt $!&! &! #$ $#$n"$, 1< tK#&t$ * p#+@#*' t+ *n*(-8$ t $ #un>t&'$ 5$ *)&+# & * FIFO '$" *n&!' &! u!$, 5-CPU !" $,u($# t+ ! *p * p*@$ #+' '$'+#-. T *t &!6 t $ +(,$!t p*@$ &n '$'+#- &! t*?+ut + '$'+#- $n t $ p*@$ 5$&n@ #$ $#$n"$, &! n+t &n '$'+#- *n, t $#$ &! n+ p*@#*'$ *)*&(*5($ t+ "+p- t $ n$ p*@$.
A!!u'$ t *t #$*( '$'+#- &! $'pt- *t t $ 5$@&nn&n@ + $ $"ut&+n.In p*#t&"u(*#6 -+u# p#+@#*' ! +u(, p#&nt1% IRI > t+t*( nu'5$# + p*@$! #$ $#$n"$,.
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 328/499
ICOM C *(($n@$ 1 4P#+@#*''&n@ C+nt$
M*#" 6 1 4
2% A t*5($ &t t $ +((+ &n@ In +#'*t&+n P*@$ #*'$! > t $ nu'5$# + p*@$ #*'$ &n #$*( '$'+#-. T &!
! +u(, #*n@$ #+' I t+ 1 .P*@$ *u(t! > t+t*( nu'5$# + p*@$ *u(t!
Page Fault Rate > average page 7ault rate 2PageF*u(t!bIRI%
E *'p($
L$t R X 2232 3.
F+# p*@$ #* '$ ! X 16 t &! &! * t @+$! +n ,u#&n@ $ $"u t&+n
P*@$ 2 &! #$ $#$n"$,6 &t &! n+t &n '$ '+#-6 !+ * p*@$ *u(t +""u#!. P*@$ 2 &! '$'+#-.P*@$ 2 I! #$ $#$n"$, *@*&n6 &t I! &n '$'+#-.P*@$ 3 &! #$ $#$n"$,6 &t &! n+t &n '$ '+#- *n, t $#$ I! n+ p*@$ #*'$ *)*&(*5(+n(- +n$ p*@$ #*'$ *n, It &! t*?$n 5- p*@$ 2%. A p*@$ *u(t +""u#!. P*@$ 2 &! ! *pp$, #+' '$'+#- *n, p*@$ 3 &! &nt+ '$'+#-.P*@$ 2 &! #$ $#$n"$, *@*&n6 &t &! n+t &n '$ '+#- *n, t $#$ &! n+ p*@$ #*'$ * p*@$ *u(t +""u#!. P*@$ 3 &! ! *pp$, #+' '$'+#- *n, p*@$ 2 &! "+p&$, &nt+ '$ '+P*@$ &! #$ $#$n"$,6 &t &! n+t &n '$ '+#- *n, t $#$ &! n+ p*@$ #*'$ *)*&(*5(*u(t +""u#!. P*@$ 2 &! ! *pp$, #+' '$'+#- *n, p*@$ &! "+p&$, &nt+ '$'+#-.
P*@$ 3 I! #$ $#$n"$,6 &t &! n+t &n '$'+#- *n, t $#$ &! n+ p*@$ #*'$ *)*&(*5($.*u(t +""u#!. P*@$ &! ! *pp$, #+' '$'+#- *n, p*@$ 3 I! "+p&$, &nt+ '$'+#-.
F+# p*@$ #*'$! X 2P*@$ 2 &! #$ $#$n"$,6 &t &! n+t &n '$ '+#-6 !+ * p*@$ *u(t +""u#!. P*@$ 2 I!*@*&n6 It I! &n '$'+#-.P*@$ 3 &! #$ $#$n"$,6 &t &! n+t &n '$ '+#-6 !+ * p*@$ *u(t +""u#!. P*@$ 2 &*@*&n6 &t &! &n '$'+#-.P*@$ &! #$ $#$n"$,6 &t &! n+t &n '$ '+#- *n, t $#$ &! n+ p*@$ #*'$ *)*&(*5(*u(t +""u#!. P*@$ 2 &! ! *pp$, #+' '$'+#- *n, p*@$ I! "+p&$, Int+ '$'+#-.
P*@$ 3 &! #$ $#$n"$,6 &t &! &n '$'+#-.
An, !+ +n.
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 329/499
E *'p($ Output +# R> 2232 3
T $ nu'5$# + p*@$! #$ $#$n"$,6 IRI6 &! :.
P*@$ F#*'$! P*@$ F*u(t! P*@$ F*u(t R*t$
1 <. 3332 3 <. <3 3 <. <4 3 <. <4 4 44 4 44 4 41 3 <. <
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 330/499
ICOM Challenge 1994Programming Contest
March 5, 1994
Tur!le Te9! +rap ic"
S+u#"$ F&($ N*'$ AD2.;;; Input F&($ N*'$ AD2.1N
M*C#+ *#, C+#p *! &#$, -+u t+ 5u&(, * !p*n?- n$ &nt$#p#$t$# "*(($, BOGUS. B$@&nUn&)$#!*( S-!t$'%. BOGUS "+n!&!t! + * t&n@ !$t + "+''*n,! u!$, t+ "#$*t$ $ t#$'$(U "#u,$ tu#t($ t$ t@#*p &"!. T $ tu#t($ &! #$p#$!$nt$, 5- t $ ($tt$# T + "+u#!$% *n, t $ tu#t($ ! t#*&( &! #$p#$!$T $ &nt$#p#$t$# #$*,! t $ &nput &($ *n, ,&!p(*-! t $ p#+@#*' ! +ut"+'$ +n !"#$$n. K $n t $ tu#t$n, + t $ !"#$$n6 t $ tu#t($ ,+$! n+t #*p *#+un,. T $ tu#t($ !&t! t $#$ unt&( *n+t $# "+''*n, t* 5*"? t+ * p+!&t&+n t+ *#,! t $ "$nt$# + t $ !"#$$n +# *(+n@ t $ $,@$ + t $ !"#$$n. A(!+6 *n- !'u!t 5$ &@n+#$,. E)$#- "+''*n, +""up&$! +n$ (&n$. In&t&*((-6 t $ tu#t($ &! &n t $ "$nt$# + 264 % *"&n@ n+#t .
T $ +((+ &n@ *#$ t $ "+''*n,! +# BOGUS
I. FKD f!t$p!ZT*?$! *n Int$@$# ; *n, '+)$! t $ tu#t($ ; !t$p! +# *#,. N$@*t&)$! *#$ p#+ &5&t$,.
2. BC f!t$p!ZT*?$! *n Int$@$# ; *n, '+)$! t $ tu#t($ ; !t$p! 5*"? *#,!. N$@*t&)$! *#$ p#+ &5&t$,.
3. RGT f*n@($ZR+t*t$! t $ tu#t($ ; ,$@#$$! t+ t $ #&@ t. V*(&, )*(u$! *#$nu'5$#! #+' t+ 3 In"(u!&)$. N$@*t&)$! *#$ p#+ &5&t$,. 4. LFT f*n@($ZR+t*t$! t $ tu#t($ ; ,$@#$$! t+ t $ ($ t. V*(&, )*(u$! *#$nu'5$#! #+' t+ 3 In"(u!&)$. N$@*t&)$! *#$ p#+ &5&t$,. . JOM .M+)$! t $ tu#t($ t+ t $ "$nt$# + t $ !"#$$n.
:. CLSC($*#! t $ !"#$$n. T $ tu#t($ #$'*&n! &n t $ !*'$ p+!&t&+n.
NOTE K$ #$"+''$n, u!&n@ t $ @+t+> - LOCATE &n BASIC% "+''*n, t+ I'p($'$nt t &! p#+@#*'
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 331/499
S*'p($ InputbOutputICOM C *(($n@$1 4P#+@#*''&n@ C+nt$!tM*#" 6 1 4
InputCLSJOMFKD RGT <FKD RGT <FKD RGT <FKD
RGT <Output
T ] ] ] ] ]
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 332/499
ICOM Challenge 1994Programming Contest
March 5, 1994
Problem 3, Pascal to C Mini-For-Converter
Source File Name: AD3.XXXInput File name: AD3.pasOutput File Name: AD3.c
Define: The for statement in the Pascal language has two formats:
For control-variable :- initial-value to final-value do program-statement;ex. for x:=1 to 5 do
n:=n+x;
For control-variable :- initial-value down to final-value do program-statement;
ex. for x:=5 down to 1 don:= n + x;
The for statement in the C language has the following format:
For (initial-expression;loop-condition ; loop-expression)Program statement ;
ex. for (x=1; x<=5; x++)n= n + x;
for (x=5;x>=1; x - -)n= n + x;
The assignment statement in Pascal has the form
variable := expression ;
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 333/499
ICOM Challenge 1994Programming Contest
March 5, 1994
where expression may be a constant, another variable, or a formula tobe evaluated.
. ~?)} ".
In C, the assignment statement has the following form:
variable - expression;
The begin and end statements in Pascal translate to open ({) and close ( } ) brackets in C. Theend in Pascal has a semicolon (;), but the close bracket in C does not.
Problem: Write a program to translate valid for statements in Pascal to the C language.Your program will read a Pascal for statement from the file AD3.pas, and will write theequivalent C statement into the file AD3.c. Your translator program must consider thecase of several assignment statements combined into a single for statement. You donot have to worry about nested for statements. You do not need to worry about arrayseither.
Sample Input/Output:
Input: for x:=l to 5 do beginn:=3;
J:=n+x;end;
Output: for (x= I; x<=5; x++){
n=3;J=n+x;
}
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 334/499
7roblem #. 5uffman Coding
S+u#"$ F&($ N*'$ A D 4. ; ; ;Input F&($ N*'$ A D 4. IN
Output F&($ N*'$ A D 4. OUT
D$ &n$Ju '*n "+,$! *#$ u!$, t+ "+'p#$!! ,*t*. On$ " *#*"t$#&!t&"! + Ju '*n "+,$! &! t *t t $ "+,$
+#,! )*#- &n t $ nu'5$# + 5&t! t $- "+nt*&n. D*t* "*n 5$ "+'p#$!!$! $ &"&$nt(- 5- *!!&@n&n#$ u$nt(- = +"u##&n@ ,*t* !-'5+(! t+ t $ ! +#t$# "+,$ +#,!6 *n, *!!&@n&n@ t $ ($!! #$ u$nt(- ,*t* !-'5+(! t+ t $ (+n@$# "+,$ +#,!.
P#+5($'K#&t$ * p#+@#*' t+ #$*, " *#*"t$#! #+' t $ A D 4. IN 6 "+unt t $ nu'5$# + +""u##$n"$!
" *#*"t$#6 t $n *!!&@n Ju '*n "+,$ +#,! t+ t $ " *#*"t$#! *! +((+ !
Ju '*n C+,$ K+#, C *#*"t$#
1 M+!t #$ u$nt<1 2n, '+!t #$ u$nt<<1 3#, '+!t #$ u$nt<<<1 4t '+!t #$ u$nt<<<<1 t '+!t #$ u$nt<<<<< :t '+!t #$ u$nt
I t $ nu'5$# + " *#*"t$#! &! t $ !*'$ +# t + ,& $#$nt " *#*"t$#!6 *!!&@n t $ Ju '*n "+,$ +#,! ASC ( ( nu'$#&"*( )*(u$ + t $ " *#*"t$#6 "+n!&,$#&n@ t $ &@ $# ASC ( ( )*(u$ *! [($*!t '*- *!!u'$ t *t $*" " *#*"t$# + t $ &nput &($ '*- 5$ 1 + *t '+!t : ,& $#$nt " *#*"t$#!.
T $n +utput t $ "+'p#$!!$, )$#!&+n + t $ &nput &($ (. $. #$p(*"$ $*" " *#*"t$# 5- &t! Ju+#,% t+ t $ &($ AD4. OUT. F+# pu#p+!$! + t &! p#+5($'6 -+u# +utput ! +u(, 5$ &n t $ +#' [1\ *n, [<\ " *#*"t$#!. K$ #$*(&8$ t *t t &! '$*n! t *t -+u *#$ n+t *"tu*((- "+'p#$!!&n@ t $ &t*?$! t $ p#+5($' $*!&$# t+ t$!t *n, t+ " $"?.%
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 335/499
0ample .nput<:utput(
.nput(
ABC#$F###C#$#CCC$$BBF
:utput(
KKKKKKKK&K&&KK&KKKK&&&&K&&KK&&K&K&K&KK&KK&KKK&
.nput(
H HH H H
:utput(
KK&K&&KKK&&K&&KK&KK&&K&&&K&KK&K&KKK&&&K&KK&
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 336/499
ICOM C *(($n@$ 1P#+@#*''&n@ C+n
M*#" 6 1 4
7roblem &. $arge Number"
S+u#"$ F&($ N*'$ AD .;;;
Input F&($ N*'$ AD .1NOutput F&($ N*'$ AD .<UT
P#+5($' K#&t$ * p#+@#*' t+ 'u(t&p(- t + (*#@$ nu'5$#! + ($n@t up t+ 3 ,&@&t!.
On$ *pp#+*" &! t+ t#$*t $*" nu'5$# *! * (&!t6 $*" + +!$ $($'$nt! &! * 5(+"? + ,&@&t! +T $n -+u "*n 'u(t&p($ t $ &nt$@$#! (&!t!% $($'$nt 5- $($'$nt. O "+u#!$6 -+u '*- u!$ * ,& $#$nY+u# p#+@#*' &(( #$*, t + nu'5$#! #+' t $ &($ AD .1N. T $ nu'5$#!6 #$p#$!$nt$, 5- !t#&n@!6 &((!$p*#*t$ (&n$!. T $ +utput ! *(( 5$ #&tt$n t+ &($ AD .<UT.
.nput(
T + Int$@$#! + ($n@t up t+ 3 ,&@&t! #$p#$!$nt$, 5- * !t#&n@ + ASCII " *#*"t$#Int$#*"t&)$(- 5-t $ u!$#.
$5ample(
T+ 'u(t&p(- 34 2 e 2 346 +n$ "+u(, ,&)&,$ 34 2 &nt+ 34 *n, 26 *n,2 34 &nt+ 2 *n, 34. T $n6
2 e 34 X 1 : 6 34 e 34 X 11 :62 e 2 X 13<<6 2 e 34 X <.
1 : 13<<
11:
<
>>>>>>>>>>> >>>>>>>>>>>> 11 3: :3<<An, &n*((-6
1>1 3::3<<
>>>>>>>>>>>>>>>>4 3:
N+t$ t *t +# t &! (*!t *,,&t&+n6 t $ nu'5$#! '*- *(!+ 5$ )$#- (*#@$. T $#$ +#$6 -+u &(( *(!+ n$$,$*" nu'5$# &nt+
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 337/499
ICOM C *(($n@$ 1 4P#+@#*''&n@ C+nt
M*#" 6 1 4
5(+"?! + ,&@&t! + t $ nu'5$#6 *n, t $n *,, t $ Int$@$#! (&!t!% 5(+"? 5- 5(+"?6 "*##-&n@ #+' +nn$ t $n n$"$!!*#-. N+t$ *(!+ t *t t $ #$!u(t&n@ p#+,u"t "*n *)$ '+#$ t *n 3 ,&@&t!. Y+u '*- *!!u'$ t *t &t &(( n+t *)$
t *n ,&@&t!.0ample .nput(
34 22 3
0ample :utput(
T $ p#+,u"t &! 4 3: .
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 338/499
University of Puerto RicoMayaguez Campus
!"#$ "%allen&e 5*8
Intermediate Division
Sponsored by
AEIC and Lucent Technologies
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 339/499
.NT$R-$#.A #./.0.:N
ProblemB, STAC MANIP0$ATION
S+u#"$ F&($ N*' ID1.;;;
.nput File Name( .#&4#AT
:utput File Name( .#&4:UT
Trite a program that converts an e>pression in infi> notation to postfi> and prefi> notation. ourprogram should Frite as output the original e>pression in infi> notation, the e>pression in postfi> andin prefi> notation. ach e>pression should be in a separate line, and properl* labeled.
Sample Inpu!:
+25#Q) "
Sample Ou!pu!:
infi> notation! +25#Q) "postfi> notation! 2# )5"prefi> notation! 5Q2# ) "
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 340/499
7roblem 2. EAS CA$ENDAR
0ource File Name( .#'4OOO.nput File Name( .#'4#AT:utput File Name( .#'4:UT
K#&t$ * p#+@#*' t *t t*?$! *! &nput * ,*t$ &t t $ +#'*t
mmmddyyyy
---- "*n 5$ *n- -$*# 5$ +#$ +# * t$# 1 3%
*n, #$tu#n! t $ ,*- + t $ $$? "+##$!p+n,&n@ t+ t *t ,*t$ &.$.6 M+n,*-6 Tu$!,*-6 $tY+u# p#+@#*' ! +u(, *(!+ t$!t +# *n- &n)*(&, &nput6 $.@. $5 2 1 3 *n, #$p+#t *n $'$!!*@$ &n t *t "*!$.
Remar3s(A @&)$n -$*# &! ,$ &n$, *! * [($*p\ -$*# & t $ -$*# &! ,&)&!&5($ 5- 4<<6 +# & & 5ut n+t 5- 1<<. F+# $ *'p($6 t $ -$*# 2<<< &! * ($*p -$*#a 1 << &! n+t * ($*p -$*#.
0ample .nput(
$5 <2 1 3
0ample :utput($5 <2 1 3 &! * Tu$!,*-
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 341/499
.NT$R-$#.AT$ #./.0.:N
EI+5T L0EENS 6IT5 A T6ISTProblem =(
E&@ t u$$n! "*n 5$ *##*n@$, +n * " $!! 5+*#, !+ t *t n+ u$$n &! un,$# *tt*"? #+' *n- + t&n +t $# +#,!6 !+ t *t n+ #+ +# "+(u'n +# ,&*@+n*( "+nt*&n! '+#$ t *n +n$ u$$n. K#&t$ * p#+@ p(*"$ t $ p+!&t&+n + u$$n! +n * " $!! 5+*#, *n, $n!u#$! t *t n+ u$$n! *#$ un,$# *tt*"?. Y+u#! +u(, &#!t ,#* t $ " $!! 5+*#, ,&!p(*-&n@ t $O '*t#& &t d! #$p#$!$nt&n@ t $ u$$n p+!&t&+n p#+@#*' 'u!t *(!+ !$*#" *n, ,&!p(*- *(( t $ !+(ut&+n! +# t &! p#+5($'. T $ *n! $#! ! +u(, ! + t $ "+!+(ut&+n.
Note( N+ *#,> &#$, !+(ut&+n *#$ *((+ $,W
0ample :utput(
1 2 3 4 :
1
2
3
4
:
PR$00 $NT$R F:R N$OT 0:!UT.:N
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 342/499
UNIVERSIDAD DE PUERTO RICO
RECINTO DE RIO PIEDRAS
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 343/499
Universidad de Puerto RicoRecinto de Río Piedras
CO-;2/2NCI"S 2 ;?O<?"-"CI@N'AA'
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 344/499
0ource File Name( PR.N&4555.nput File Name( 555:utput File Name( 555
#irecciones generales(T+,+! (+! p#+5($'*! ,$ $!t* "*t$@+#`* !$#_n &nt$#*"t&)+!. E!t+ $!6 n+ ($$#_n ,*t* ,$ n&n@/n *$nt#$@*# $( ,&!"+ "+n tu p#+@#*'* t*n p#+nt+ "+'+ (+ *-*! t$#'&n*,+. E( $ u&p+ "+n '$0+# t&$'p#$!+()$# t+,+! (+! p#+5($'*!% !$#_ $( @*n*,+# ,$ $nt#$ (+! $ u&p+! u$ "+'p($t$n $( '&!'+ n/ p#+5($'*! !*t&! *"t+#&*'$nt$.
;?O,L2-" B'
ARC5IHO DE CODI+O: PRINB,999
L* !$#&$ >@$n$#*(&8*,* ,$ n/'$#+! F&5+n*""& $!t* ,$ &n&,* "+'+
7 K 7 & 4 4 4 7 23>&6 K y 7 3 &
7 2n^3^&6 7 2n^3>&6^ 444 ^ 7 n para toda n K
D$5$! $!"#&5&# un p#+@#*'* u$ ($* p*#$! ,$ n/'$#+! $nt$#+!n - 3 - @$n$#$ (+! p#&'$#+!n n/'$#+ ,$ (* !$#&$ F&5+n*""& ?>
@$n$#*(&8*,* "+##$!p+n,&$nt$.
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 345/499
.NT$RACC.:N(
Ent#$ $( p*#_'$t#+ ? p*#* (* !$#&$ &5+n*""& ?>@$n$#*(&8*,*
< p*#* t$#'&n*#% 3
P+# *)+# $nt#$ (* "*nt&,*, ,$ $($'$nt+! ,$ ,&" * !$#&$
L+! p#&'$#+! $($'$nt+! ,$ (* !$#&$ &5+n*""& ?>@$n$#*(&8*,* !+n
Posición N)mero< <
1 <2 <3 14 1
2: 3
Entre el parámetro k para la serie fibonacci k-generalizada< p*#* t$#'&n*#% <
9racias
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 346/499
PR:B!$-A '
ARC5IHO DE CODI+O: PRIN4,999
E!"#&5$ un p#+@#*'* u$ ($* n/'$#+! $nt$#+!6N6 - u$ "*("u($ $( *"t+#&*( ,$N $ *"t*'$nt$
p*#* "u*( u&$# $nt$#+ N f 1<<. E( *"t+#&*( ,$ un n/'$#+ $!t_ ,*,+ p+#
NW X 1 2 3 N
.NT$RACC.:N(
F*)+# ,$ $nt#*# un n/'$#+ $nt#$ 1 - 1<< < p*#* t$#'&n*#% E( *"t+#&*( ,$ $! 12<
F*)+# ,$ $nt#*# un n/'$#+ $nt#$ 1 - 1<< < p*#* t$#'&n*#% 1< E( *"t+#&*( ,$ 1< $! 3:2 <<
F*)+# ,$ $nt#*# un n/'$#+ $nt#$ 1 - 1<< < p*#* t$#'&n*#% <G#*"&*!W
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 347/499
0ource File Name( PR.N=4555
L* un"&7n ,$ A"?$#'*n $!t_ ,$ &n&,* "+'+
* ' 6 n% X n 1 "u*n,+ ' X <* ' 6 n% X * '>16 1% "u*n,+ ' fZ < - n X <
* ' 6 n% X * '>16 * '6 n>1%% "u*n,+ ' fZ < - n fZ <
D$5$! $!"#&5&# un* un"&7n u$6 ,*,+ ,+! n/'$#+! n - '6 "*("u($ * '6n%. D$5$! t*5u(*# (+! )*(+#$! ,$ * '6n% p*#* t+,*! (*! ' t*( u$ 1 i ' i 4 - t+,*! (*! n t*( u$ 1i n i 1<.E!t$P#@#*'* n+ t&$n$ &nput.
Output
Funci n de "c$erman
& ' = + , L V &K& 55 >> >> >> >> >> >> >> V> >>
' 55 >> >> >> >> >> >> >> V> >>
= 55 >> >> >> >> >> >> >> V> >>
+ >> >> >> >> >> >> >> >> V> >>
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 348/499
PR:B!$-A +
ARC5IHO DE CODI+O: PRINQ,999
D$5$! $!"#&5&# un p#+@#*'* u$ ($* un n/'$#+ N $nt$#+ &'p*# p+!&t&)+ $ &'p#&'* un "u*,#*,+Un "u*,#*,+ '_@&"+ N N "+nt&$n$ (+! n/'$#+! $nt$#+! ,$( 1 *( N2 ,$ +#'* t*( u$ (*! !u'*! ,$ (+!$($'$nt+! ,$ "*,* &(*6 "+(u'n*6 - ,&*@+n*( p#&n"&p*( !+n &@u*($!. Un *(@+#&t'+ p*#* "+n'_@&"+ !$#`*
E( *(@+#&t'+ *!u'$ u$ (+! `n,&"$! ,$( "u*,#*,+ !+n ,$( 1 *( N $n *'5*! ,&'$n"&+n$!.
P*!+ IC*("u($ F X P*#t$ $nt$#* ,$ N 1% b 2C*("u($ C X N
P*!+ IIC+(+ u$ 1 $n (* &(* F "+(u'n* C ,$( "u*,#*,+
P*!+IIIEn "*,* &nt$#*"&7n * "+nt&nu*"&7n6 "+(+ u$ $( !&@u&$nt$ n/'$#+ $n (* !$"u$n"&* 2>ZN2 $n,$( "u*,#*,+ '_@&"+In"#$'$nt$ $n "*,* &nt$#*"&7n *'5*! F - C $n 1 '7,u(+ N%= p+# N>1 )$"$!. C+(+ u$ $( p#7 &'+ n/'$#+ (* !$"u$n"&*.En (* !&@u&$nt$ &nt$#*"&7n #$,u8"* F $n 1 '7,u(+ N% - n+ "*'5&$ C. "+(+ u$ $( p#7 &'+ n/'$#"+(u'n* C.R$p&t* (+! p*!+! 5 - " *!t* u$ *-* "+(+"*,+ t+,+! (+! n/'$#+! *t* $( N2 $n $( "u*,#*,+ '_@&"+
= En $!t$ p#+5($'* ['7,u(+ N\ u&$#$ ,$"&# u$ !& '_! '$n+!% 1 $! &@u*( * N 1 <% $nt+n"$! p*N%.
E0$'p(+6 !& N X 3 - X 3 $nt+n"$! 1 '7,u(+ N $! 1.E0$'p(+6 !& N X 3 - X 1 $nt+n"$! = 1 '7,u(+ N $! N.
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 349/499
INTERACCION
Ent#$ (* ,&'$n"&7n N ,$( "u*,#*,+ '_@&"+ < p*#* t$#'&n*#% 3
Cu*,#*,+ '_@&"+ p*#* N X 3
3: 12 4
Ent#$ (* ,&'$n"&7n N ,$( "u*,#*,+ '_@&"+ < p*#* t$#'&n*#% <G#*"&*!W
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 350/499
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 351/499
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 352/499
Universidad de Puerto RicoRecinto de Río Piedras
CO-;2/2NCI"S 2 ;?O<?"-"CI@N'AA'
+ perto
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 353/499
$OP$RT #./.0.:N
$ON+ $ON+ DIHISION
Problem: BY+u *)$ 5$$n *!!&@n$, t+ * t$*' + !+ t *#$> *#, *#$ $n@&n$$#! +#?&n@ +n !up$# "+'put$#! ,$Y+u# t*!? &! t+ #&t$ !+ t *#$ +# &'p($'$nt&n@ 'u(t&p($ ,&@&t ,&)&!&+n6 &" &! t+ ,&)&,$ *$ $# ,&@&t! 5- *n- p+!&t&)$ ,&)&!+# ($!! t *n 1<<.
D*t* &n t $ &nput &($! "+'$! &n p*&#!6 &t t $ &#!t (&n$ "+nt*&n&n@ t $ ,&)&,$n, *n, t $ !$"+t $ ,&)&!+#. Y+u# p#+@#*' &! t+ *""$pt +n(- "+##$"t ,&)&,$n,! *n, ,&)&!+#!. T u!6 & $&t $# t,&)&!+# "+nt*&n! *n- n+n>,&@&t6 &.$.6 * " *#*"t$# n+t &n Q<.. 6 +# t $ ,&)&!+# &! @#$*t$# t$##+# '$!!*@$6 *! ! + n &n t $ !*'p($ +ut ! + n 5$(+ .
I -+u #$*, &n t + )*(&, )*(u$!6 -+u *#$ t+ "+'put$ t $ u+t&$nt *n, #$'*&n,$# *n, +utput t $ #$!u(t! *+n t $ !*'p($ +utput ! + n 5$(+ . Y+u *#$ t+ u!$ n+#'*( $n,>+ > &($ '$t +,! t+ t$#'&n*t$ -+u# #$*,! t $ &nput ,*t* &($. A( *-! !?&p * (&n$6 *! ! + n 5$(+ &n t $ $ *'p($ ,*t*6 5$t $$n t $ ,&)&,$n, p*&#!.
0ample #ata(
V==
0ample output(
2N/2? FI?S/ N1-,2?8 A$NT$R 0$C:N# NU-B$R =
ividend is A#ivisor is =Euotient is =Remainder is K
$NT$R F.R0T NU-B$R =$NT$R 0$C:N# NU-B$R
#ividend is =#ivisor is Euotient is Remainder is +
$NT$R F.R0T NU-B$R KM$O.T
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 354/499
TJE DATABASE PROBLEM
S+u#"$ F&($ N*'$ ED2.;;;Input F&($ N*'$ ED2.DAT
Output F&($ N*'$ ED2.OUT
#e7ine(
T $#$ &! * !t*n,*#, ,*t*5*!$ !t#u"tu#$6 "*(($, * !$t6 &" #$p#$!$nt! * t + ($)$( &$#*#" - 5$t,& $#$nt #$"+#, t-p$! = +n$ "*(($, t $ + n$# *n, t $ +t $# "*(($, t $ '$'5$#. T &! "+n!t#u"t &! u#$p#$!$nt * 1 t+ '*n- &.$.6 1 N% #$(*t&+n! &p 5$t $$n #$"+#, t-p$!. T $ + n$# #$"+#, &! t $ 1#$(*t&+n! &p *n, t $ '$'5$# &! t $ N &n t $ 1 N #$(*t&+n! &p. An $ *'p($ + t &! #$(*t&+n! &pt-p$% &! ! + n &n t $ &@u#$ 5$(+ . T $ &@u#$ 5$(+ &n,&"*t$! * 1 N #$(*t&+n! &DEPARTMENT #$"+#, *n, t $ FACULTY #$"+#,. It "+>n+t$! t *t t $#$ "*n 5$ N F*"u(t- '$*!!+"&*t$, &t $*" ,$p*#t'$nt. B$ * *#$ t *t t $ N "*n 5$ 8$#+W
M> The :?ner Record
M> M>The -ember Record
9 783J@ CJ
;84ULJ
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 355/499
An occurrence o7 this set could be as 7ollo?s(
B$ * *#$ t *t t &! &! +n(- +n$ +""u##$n"$ + t $ !$t t-p$. T $#$ "+u(, 5$ *n+t $# +""u##$n"$ +# t $D$p*#t'$nt6 *n+t $# +""u##$n"$ +# t $ A""+unt&n@ D$p*#t'$nt6 $t". A(!+ n+t$ t *t t $ n*'$! &n tDEPARTMENT #$"+#, E($"t#&"*( En@&n$$#&n@% *n, t $ FACULTY #$"+#,! SCOTT6 TJOMGAGNON% *#$ u!$, t+ &n,&"*t$ t $ #$"+#, +""u##$n"$!. T $#$ "+u(, 5$ *,,&t&+n*( &n +#'*t&+n"+n"$#n&n@ t $ DEPARTMENT $t".6 C *&#'*nv! N*'$6 D$p*#t'$nt6 L+"*t&+n6 Bu,@$t6 $t".% *FACULTY $ .6 A@$6 S*(*#-6 A,,#$!!6 $t".% !t+#$, &n t $ #$"+#,.
Problem(
Y+u *#$ t+ #&t$ * p#+@#*' t+ &'p($'$nt t &! !$t !t#u"tu#$. Y+u# p#+@#*' ! +u(, *""$pt unput #$""+nt*&n )*#&+u! !$t "+''*n,!. T $!$ "+''*n,! *#$ t+ p#+,u"$ )*#&+u! *"t&+n!. T $!$ *"t&+n! *#$!u''*#&8$, 5$(+ 6 *! $(( *! t $ +#'*t! + $*" +t t $ "+''*n,! ,$!"#&5$, +#'*t !t*t$'$nt &! #&tt$n &n 5+(,%. A(( &nput #$"+#,! "*n 5$ "+,$, &n #$$ &$(, +#'*t. T $ +n(- ,$(&'&t$#! *#$ 5(*n?!.
ADD DEPARTMENT = A,, * n$ ,$p*#t'$nt*( + n$#% #$"+#, +""u##$n"$ t+ t $ ,*t*5*!$.
A## #$PART-$NT department S name department S budget
$lectrical engineering
9agnon
Roggio
0cott
Thomas
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 356/499
2. ADD FACULTY > A,, * n$ *"u(t- '$'5$#% #$"+#, +""u##$n"$ t+ t $ ,*t*5*!$. E*" n$*"u(t- #$"+#, 'u!t 5$ *!!+"&*t$, &t * ,$p*#t'$nt*( #$"+#,
A## FACU!T 7aculty S member S last>name salary deaprrment>name
3. LIST DEPARTMENT = (&!t t $ n*'$! + *(( + t $ *"u(t- '$'5$#! *!!+"&*t$, &t * ,$p*#t'$nt. !.0T #$PART-$NT department>name4. LIST FACULTY> L&!t t $ n*'$ *n, !*(*#- + t $ !p$"& &" *"u(t- '$'5$#.
!.0T FACU!T 7aculty S member>last>name department>name
. STOP> St+p p#+""$!&n@.
0T:P
Assumptions(1. Y+u '*- *!!u'$ t *t budget *n, salary ,*t* *#$ ($!! t *t :<6<<<.
2. Y+u '*- *!!u'$ t *t *(( &nput ,*t* &! &n upp$#"*!$.
3. T $ '* &'u' ($n@t + t $ department name*n, t $ 7aculty name&! 2< " *#*"t$#!.
4. Y+u '*- *!!u'$ t *t t $#$ &(( n$)$# 5$ * LIST DEPARTMENT +# * LIST FACULTY "+''*n,+# * DEPARTMENT +# * FACULTY '$'5$# t *t ,+$! n+t $ &!t.
. T $#$ &(( n$)$# 5$ * LIST FACULTY "+''*n, +# * *"u(t- '$'5$# + &! (&!t$, &n t $ #+n@,$p*#t'$nt.
:. T $#$ &(( n$)$# 5$ *n ADD FACULTY "+''*n, &" "+nt*&n! * D$p*#t'$nt &" ,+$! $ &!t
:utput ReGuirements(
1. A(( &nput #$"+#,! ! +u(, 5$ $" +$,.
2. T $ +utput #+' t $ LIST FACULTY "+''*n, ! +u(, (++? *! +((+ !
FACULTY *"u(t->n*'$SALARY !*(*#-
3. T $ +utput #+' t $ LIST DEPARTMENT "+''*n, ! +u(, (++? *! +((+ !
DEPARTMENT ,$p*#t'$nt>n*'$
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 357/499
BUDGET 5u,@$t
4. I t $#$ &! *n &(($@*( "+''*n, ,&!p(*- t $ +((+ &n@ '$!!*@$ *n, "+nt&nu$ p#+"$!!&n@.
ERROR IN COMMAND
. I t $#$ &! *n $##+# &n $&t $# t $ ADD +# LIST "+''*n,!6 ,&!p(*- t $ *pp#+p&*t$ $##+# '
ADD C+''*n, $##+# LIST C+''*n, $##+#
:. D+u5($ !p*"$ *(( +utput $ "$pt $#$ n+t$,. S$$ +utput #$ u&#$'$nt! 2 *n, 3%.
0ample #ata(
A## #$PART-$NT $!$CTR.CA! S$N9 KKKKA## #$PART-$NT .N#U0TR.A! S $N9 =KKKKA## FACU!T $0P:0.T: ' KKK .N#U0TR.A! S$N9A## FACU!T 9A9N:N ''KKK $!$CTR.CA! S$N9A## FACU!T 9A9N:N $!$CTR.CA! S$N9!.0T FACU!T 9A9N:N $!$CTR.CA!> $N9
!.0T #$PART-$NT $!$CTR.CA!>$N90T:P
0ample :utput(
A## #$PART-$NT $!$CTR.CA! S$N9 KKKKA## #$PART-$NT .N#U0TR.A! S$N9 =KKKKA## FACU!T $0P:0.T: ' KKK .N#U0TR.A! S$N9A## FACU!T 9A9N:N ''KKK $!$CTR.CA! S$N9FACU!T ( 9A9N:N0A!AR ( ''KKK#$PART-$NT( $!$CTR.CA!>$N9BU#9$T( KKKK
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 358/499
UPR P#+@#*''&n@ C+ntP#+5($' S$t
M*#" 6 2 1 1
7roblem "! +O$D#AC5 CON(ECT0RE
S+u#"$ F&($ N*'$ ED3.;;;
Input F&($ N*'$ ED3.DATOutput F&($ N*'$ ED3.OUT
#e7ine(
T $ G+(,5*" "+n0$"tu#$ !t*t$! t *t *n- p+!&t&)$ $)$n nu'5$# @#$*t$# t *n 4 "*n 5$ $ p#$!!$, *+ t + p#&'$ nu'5$#!. T &! "+n0$"tu#$ *! n$)$# 5$$n "+'p($t$(- p#+)$n6 5ut &t *! 5$$n ,$'+n 5- "+'put$# t+ 5$ t#u$ +# * &,$ #*n@$ + $)$n nu'5$#!.
Problem(
G&)$n *n $)$n nu'5$# @#$*t$# t *n 46 &n, t + p#&'$ nu'5$#! &" !u' t+ &t. F+# pu#p+!$ p#+5($'6 1 &! n+t "+n!&,$#$, * p#&'$ nu'5$#.
.nput(
Input +# t &! p#+5($' "+n!&!t! + * (&!t + $)$n nu'5$#! @#$*t$# t *n 46 +n$ p$# (&n$. T $ n 5$ $ $# t *n 1< ,&@&t! &n ($n@t .
:utput(
E*" (&n$ + t $ p#+@#*' +utput "+n!&!t! + $ *"t(- t #$$ $nt&t&$! t $ +#&@&n*( &nput nu'5
p#&'$! &" !u' t+ t *t nu'5$#.0ample #ata(
1<
0ample :utput(
O#&@&n*( P#&'$3
1<
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 359/499
UPR Programming ContestProblem Set
March 2, 1991
Problem +( CA$C0$ATOR
Source File Name: ED4.XXXInput File Name: ED4.DATOutput File Name: ED4.OUT
Problem:
You are to write a program which can evaluate simple expressions. The expression can contain thefollowing t~-q;:ms:
decimalnumber:operators:parenthesis:
optional sign, the digits 0-9 and decimal point,+, -, *, or/,( or ) to specify precedence grouping.
You can assume that the expression should be evaluated right to left, except where parenthesis grouping isfound. You can also assume that all input expressions are syntactically correct and that each token is separatedby exactly one blank space. All expressions will be less than 50 characters in length.
When an input expression is read, you are to print that expression and it's value correct to 6 decimal places.
Sample Data:
1 + 22 * 1.3 / ( 77 * 88 )
Note that · is equivalent to a space.Sample Output:1 + 2 = 3.0000002 * 1.3 / ( 77 * 88 ) = .000384
Page 9
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 360/499
7roblem ' W Pa! *inder
S+u#"$ F&($ N*'$ ED1.
Input F&($ N*'$ ED1.DATOutput F&($ N*'$ ED1.Out
P#+5($'Bu&(, * (&!t #+' * !$t + &nput p*&#! &,$nt& -&n@ * !t*#t *n, $n, p+&nt + (&n? +n * p*t .
A t#*"$ t $ p*t t+ p+&nt E. Output t $ p*t t *t *! t $ ($*!t (&n?!.
F+# $ *'p($F+# t $ +((+ &n@ p*&#!
A6BB6CC6DD6E
T $ p*t #+' A t+ E &! ABCDE.
S*'p($ D*t*A6LA6BL6DD6C
C6EB6FS*'p($ Output
T $ p*t #+' A t+ E &! ABFE
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 361/499
7roblem 2 W T e uca Complier
Source File Name: ED2.xxx
!nput 9ile 4ame: +-'.-2;
#utput 9ile 4ame: +-'.#ut
D$ &n&t&+nA !t#&n@ &! *n- "+'5&n*t&+n + 5(*n?!6 ($tt$#!6 ,&@&t! *n, !p$"&*( " *#*"t$#. K+#, *#$ @#+u!$p*#*t$, 5- 5(*n?!.
P#+5($'D$)$(+p * YUCA (*n@u*@$ p*#!$#b"+'p&($#. T $ YUCA Yu-+d! Un"($ C+'p&($# bA!!$'5($#% (*n,($ up t+ 2< )*#&*5($!6 *(( + &" *#$ @(+5*(. V*#&*5($! "*n 5$ up t+ : " *#*"t$#! (+n@. On(4< " *#*"t$#!% "*n 5$ *!!&@n$, t+ )*#&*5($. A )*#&*5($ "*n !t+#$ !t#&n@! up t+ 4< " *#*"t$#!.
A YUCA p#+@#*''$# "*n u!$
1% *n INVERT un"t&+n6 &" &(( #$)$#!$ t $ !t#&n@. +n$ *#@u'$nt%2% * PRINT un"t&+n6 &" &(( p#&nt t $ )*(u$ +# )*#&*5($. +n$ *#@u'$nt%3% * BEGIN !-'5+(6 &" &! u!$, t+ '*#? t $ 5$@&nn&n@ + * p#+@#*'.4% * END !-'5+(6 &" &! u!$, t+ '*#? t $ $n, + * p#+@#*'.
A(( un"t&+n! *#$ #$!$#)$, !-'5+(!. T $ YUCA "+'p&($# ! +u(, p#&nt *n $##+# &
An- un"t&+n n*'$ &! u!$, *! * !-'5+(. An- un*!!&@n$, !-'5+( &! u!$, &n * un"t&+n. An- un,$ &n$, un"t&+n &! u!$,.
A(!+ !-nt* $##+#! ! +u(, 5$ (*@@$,6 BUT NOT DESCRIBEDWWW. N+ n$!t$, un"t&+n! *#$ YUCA (*n@u*@$. NO NEED TO CJEC FOR CASE SENSITIVITY.
T $ "+'p&($# "*n #$*, up t+ p#+@#*'! *! ,*t*.
A !*'p($ YUCA p#+@#*' &!BEGINA1 X\BATATA\aA2 X\PLATANO\aA3 X [FOO\aINVERT A3%
PRINT A3%aPRINT A1%aEND
BEGON
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 362/499
A1 X\FOO\aEND
*n, &t! +utput &(( 5$
P#+@#*' 1OOFBATATA
P#+@#*' 2S-nt* E##+# *t (&n$ 1
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 363/499
7roblem " Mo.ie $i"!ing" Da!aba"e
0ource File Name( $#=4555Input F&($ N*'$ ED3. DATOutput F&($ N*'$ ED3.OUT
D$ &n&t&+nA !t#&n@ &! *n- "+'5&n*t&+n + 5(*n?!6 ($tt$#!6 ,&@&t! *n, !p$"&*( " *#*"t$#!.
P#+5($'R$*, * !$t + ,*t* t&'$! *n, '+)&$!% &nt+ * ,*t*5*!$ *n, #$t#&$)$ *(( '+)&$! p(*-&n@ 5$t $$n "$#t*n, #$t#&$)$ *(( t&'$! +# t $ '+)&$ [ROC Y \ *! t $ (*!t u$#-. T $ #$t#&$)$ u$#- *! t $ +#'*t
RMstart>time Mend>time
N+ ,*t* &(( +((+ *n- u$#-. N+ n$$, +# $##+# " $"?&n@% T $ &n,&"*t+# +# t $ 5$@&nn&n@ *n $'pt- (&n$.
T $ t&'$ &(( 5$ t $ &#!t " *#*"t$#! + t $ &nput (&n$6 +((+ $, 5- * "+''* 6% *n, * !t#&n@ + ($!! " *#*"t$#! "+nt*&n&n@ t $ n*'$ + t $ '+)&$.
T $ p#+@#*' ! +u(, *n,($ &n"+##$"t &nput ,*t*. D*t* " $"?! ! +u(, 5$ '*,$ +# &(($@*( t&'$!.
F+# $ *'p($In t $ +((+ &n@ &nput
3<6 ROC Y <<6 T2
1< <<6 BLUE VELVET
R 3< <<
T $ +utput ! +u(, 5$P(*-&n@ 5$t $$n 3< *n, << *#$ ROC Y 6 T2 ROC Y 5$&n@ p(*-$, *t 3<.
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 364/499
7roblem # W Direc!or% Searc
S+u#"$ F&($ N*'$ ED4.Input F&($ N*'$ ED4.DATOutput F&($ N*'$ ED4.OUT
D$ &n&t&+nK+#,! *#$ @#+up! + " *#*"t$#! !$p*#*t$, 5- 5(*n?!.
P#+5($'K#&t$ * p#+@#*' t+ #$*, * \'ut&(*t$,\ +#, #$p#$!$nt&n@ * n*'$ *n, !u5!t&tut$ t $ "(+!$!t '*t" &n@["+##$"t$,\ n*'$! #+' * (&!t + ["+##$"t\ n*'$!. T+ ,$t$#'&n$ t $ "(+!$!t '*t" &n@ n*'$6 *!!u'$ t $ &#($tt$# *! t+ '*t" 6 t $ +#, *! t+ 5$ &t &n 2 " *#*"t$#! + t $ !$($"t$, [ "+##$"t\ n*'$6 *n, t $ !$($"t$,["+##$"t\ n*'$ *! t $ '+!t " *#*"t$# '*t" $! &t t $ 'ut&(*t$, n*'$ "+unt +n(- '*t" &n@ " *#*"t$#!#$@*#,($!! + p+!&t&+n%.
A!!u'$ t *t n*'$! "+nt*&n +n(- "*p&t*( ($tt$#!. T $ &nput &($ &(( "+n!&!t + * (&!t + up t+ ["+##n*'$!6 +((+ $, 5- up t+ 2< [&n"+##$"t\ n*'$!. B+t + t $!$ (&!t! &(( 5$ !$p*#*t$, 5- *n $'pt- (&n$.
F+# $ *'p($6 +# *n &nput +
HENNIFER TRACYHEANINESANDRAHOSEPJ
HENIFER HOSETRAPPER
T $ +utput ! +u(, 5$
M*t" +# HENIFER &! HENNIFER M*t" +# HOSE &! HOSEPJM*t" +# TRAPPER &! TRACY
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 365/499
7roblem &GPu11le
Source File Name: ED5.xxxInput F&($ N*'$ ED .DATOutput F&($ N*'$ ED .OUT
P#+5($' Y+u *#$ t+ #&t$ * p#+@#*' &" &(( !"*n * 1< 1< " *#*"t$# @#&,6 *n, &n, t $ +""u##$n p*#t&"u(*# +#, &n t $ @#&,. T $ +#, "*n 5$ +un, +#&8+nt*((-6 )$#t&"*((-6 ,&*@+n*((- ON AN
F+# &n!t*n"$6 @&)$n * @#&, 4 4%
A B # O
O J P
J K U P
P L U P
*n, t $ n$ t &nput 5$&n@BOKLPULPPULL
$ p#+@#*' ! +u(, p#&nt t $ (+"*t&+n + t $ +#,6 (&?$
BOKL &! &n p+!&t&+n!6 261%6 262%6 263%6 264%.PULP &! &n p+!&t&+n! 164%6 264%6 364%6 464%T $ +#, PULL &! n+t &n t $ @#&n,.
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 366/499
Problem 8) T e P%ramidU Sor!
S+u#"$ F&($ N*'$ ID2.Input F&($ N*'$ ID2.DATOutput F&($ N*'$ I,2.OUT
D$ &n&t&+nA !t#&n@ &! *n- "+'5&n*t&+n + 5(*n?!6 ($tt$#6 ,&@&t! *n, !p$"&*( " *#*"t$#!. K+#,! *#$ @#+u!$p*#*t$, 5- 5(*n?!.
P#+5($'K#&t$ * p#+@#*' t *t &(( #$*, * (&!t + &nt$@$#! up t+ 3<%6 *n, !+#t t $' p(*"&n@ t $ (*#@$!t n'&,,($6 t $ !$"+n, (*#@$!t t+ t $ ($ t + t $ (&!t6 t &#, (*#@$! t+ t $ #&@ t + t $ (&!t6 *n, !+ +n.
F+# $ *'p($6 & $ !+#t6 46 6 2<6 12
$ &(( *)$6 126 2<6 6 4
T $ p#+@#*' ! +u(, +#? +# 5+t $)$n *n, +,, nu'5$# + $($'$nt! &n t $ (&!t. F+# $)$n nu'5$#!6 t $ (*#nu'5$# ! +u(, 5$ p(*"$, &n t $ Nb2 1 p+!&t&+n6 t $ +((+ &n@ &t t $ !*'$ p*tt$#n.
F+# $ *'p($ 16 26 36 46 6 :
K&(( 5$ !+#t$, *! 16 36 6 :6 46 2
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 367/499
UNIVERSIDAD INTERAMERICANADE PUERTO RICO
RECINTO DE BAYAMÓN
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 368/499
Fma" O$IMPIADAS DE PRO+RAMACIONINTER#A 4 8
E-PERTOS
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 369/499
Problem: Ma!ri9 Ma!c er
Inpu!: tandard 6nputOu!pu!: tandard Butput
G&)$n *n N e M '*t#& 6 -+u# t*!? &! t+ &n, t $ nu'5$# + +""u##$n"$! + *n ; e Y p*tt$#n.
Inpu!T $ &#!t (&n$ "+nt*&n! * !&n@($ &nt$@$# t t i 1 %6 t $ nu'5$# + t$!t "*!$!. F+# $*" "*!$6 t $ &#!t (&n$ "+nt*&n! tN6 M i 1<<<%. T $ n$ t N (&n$! "+nt*&n M " *#*"t$#! $*" . T $ n$ t (&n$ "+nt*&n! t + &nt$@$#! ; *n, Y ;6 Y i 1<<%(&n$! "+nt*&n Y " *#*"t$#! $*" .
Ou!pu!F+# $*" "*!$6 +utput * !&n@($ &nt$@$# &n &t! + n (&n$6 t $ nu'5$# + +""u##$n"$!.
Sample inpu!21 1x1 1F3 3abc
bc* c*e2 2
bcc*
Ou!pu! for Sample Inpu!
02
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 370/499
Problem ( Pic3>up stic3s
St*n *! n !t&"?! + )*#&+u! ($n@t !. J$ t #+ ! t $' +n$ *t t&'$ +n t $ (++# &n *#*n,+' *-. A t$# &n&! &n@ t #+ &n@6 St*n t#&$! t+ &n, t $ t+p !t&"?! t *t *#$t $!$ !t&"?! !u" t *t t $#$ &! n+ !t&"? +n t+p + t $'. St*n *! n+t&"$, t *t t $(*!t t #+ n !t&"? &! *( *-! +n t+p 5ut $ *nt! t+ ?n+ *(( t $ !t&"?! t *t *#$ +nt+p. St*n !t&"?! *#$ )$#-6 )$#- t &n !u" t *t t $&# t &"?n$!! "*n 5$ n$@($"t$,.
Input "+n!&!t! + * nu'5$# + "*!$!. T $ ,*t* +# $*" "*!$ !t*#t &t1 i n i10000 6 t $ nu'5$# + !t&"?! +# t &! "*!$. T $ +((+ &n@n (&n$! "+nt*&n +u#nu'5$#! $*" a t $!$ nu'5$#! *#$ t $ p(*n*# "++#,&n*t$! + t $ $n,p+&nt! + +n$!t&"?. T $ !t&"?! *#$ (&!t$, &n t $ +#,$# &n &" St*n *! t #+ n t $'. Y+u '*-*!!u'$ t *t t $#$ *#$ n+ '+#$ t *n 1<<< t+p !t&"?!. T $ &nput &! $n,$, 5- t $"*!$ &t n X <. T &! "*!$ ! +u(, n+t 5$ p#+"$!!$,.
F+# $*" &nput "*!$6 p#&nt +n$ (&n$ + +utput (&!t&n@ t $ t+p !t&"?! &n t $ +#'*t@&)$n &n t $ !*'p($. T $ t+p !t&"?! ! +u(, 5$ (&!t$, &n +#,$# &n &" t $- $#$t #+ n.
T $ p&"tu#$ t+ t $ #&@ t 5$(+ &((u!t#*t$! t $&#!t "*!$ #+' &nput.
0ample .nput"1 1 $ 22 " " '' G2 . 0 % #' # % 2" " $ G2 . 0"0 0 ' '' 0 2 '2 0 " '0
:utput 7or 0ample .nput'op stic s: 2, $, "&'op stic s: 1, 2, 3&
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 371/499
In Op$#*t&n@ S-!t$'! * !p$"&*( #$!+u#"$>*((+"*t&+n @#*p *(@+#&t ' "*n 5$ u!$, t+ ,$t$"t $t $# t $#$ &! *n- ,$*,(+!-!t$'. A #$!+u#"$>*((+"*t&+n @#*p &! * ,&#$"t$, @#*p "+n!&!t&n@ + t + ,& $#$nt t-p$! + n+,$! P P 16 P 26 .6 P n6 t $ !$t"+n!&!t&n@ + *(( #$!+u#"$ t-p$! &n t $ !-!t$'.
A ,&#$"t$, $,@$ #+' p#+"$!! P & t+ #$!+u#"$ R 06 &! ,$n+t$, 5- P & w R 0 *n, '$*n! t *t p#+"$!! P & #$ u$!t$, *n &n!t*n"$ #$!+u#"$ t-p R 06 *n, &! "u##$nt(- *&t&n@ +# t *t #$!+u#"$. A ,&#$"t$, $,@$ #+' #$!+u#"$ t-p$ R 0 t+ p#+"$!! P &6 &! ,$n+t$, 5- R 0w P & *n, '$*n! t *t *n &n!t*n"$ + #$!+u#"$ t-p$ R 0 *! 5$$n *((+"*t$, t+ p#+"$!! P &.
T $ +((+ &n@ &@u#$ &((u!t#*t$! * #$!+u#"$>*((+"*t&+n @#*p $#$ p#+"$!!$! *#$ ,$n+t$, 5- "&#"($! *n, #$!+u#"$t *t & t $#$ &! * "&#"u(*# *&t *'+n@ t $ p#+"$!!$!6 t $n &t &'p(&$! t *t * ,$*,(+"? *! +""u##$,.
S$ u$n"$ D>">E>$>G>
G&)$n * #$!+u#"$ *((+"*t&+n @#*p &n &" $*" #$!+u#"$ t-p$ *! $ *"t(- +n$ &n!t*n"$6 -+u# 0+5 &! t+ ,+ ,$t$#'&n$* ,$*,(+"? &n t $ !-!t$'. In "*!$ * ,$*,(+"? $ &!t!6 -+u 'u!t *(!+ ! + t $ !$ u$n"$ + p#+"$!!$! *n, #$!+u#"$! &n)+()$,.
.NPUTThe input begins ?ith a single positive integer on a line by itsel7 indicating the number o7 cases 7ollo?ingJ each o7 them described belo?4 This line is 7ollo?ed by a blan3 lineJ and there is also a blan3 line bet?een t?o consecutive inputs4
K$ &(( *!!u'$ t *t t $ p#+"$!!$! *#$ n*'$, 5- "*p&t*( ($tt$#! *n, #$!+u#"$! 5- !'*(( ($tt$#!6 !+ $ (&'&t t+ 2: t $ nu'5$# + p#+"$!!$! *n,b+# #$!+u#"$!. T $#$ +#$6 t $ &#!t (&n$ + &nput "+n!&!t! + t #$$ nu'5$#! N 6 M *n, 6 #$!p$"t&)$(-6 t $ nu'5$# + p#+"$!!$!6 t $ nu'5$# + #$!+u#"$! *n, t $ nu'5$# + $,@$!. T $ $,@$! *#$ @&)$n &n t $ +((+ &n@ (&n$! *! p*&#! + ($RD^ " *#*"t$#. E,@$! *#$ !$p*#*t$, 5- !p*"$! +# n$ (&n$!.
:UTPUTFor each test caseJ the output must 7ollo? the description belo?4 The outputs o7 t?o consecutive cases ?ill be separated byblan3 line4
T $ +utput 'u!t 5$ RNK_ & n+ ,$*,(+"? &! ,$t$"t$,. In "*!$ $ ,$*,(+"? &! ,$t$"t$,6 t $ +utput 'u!t 5$RIE;_ +((+ $, 5- t $!$ u$n"$ +# !$ u$n"$! + "&#"u(*# *&t! ,$t$"t$,6 +n$ p$# (&n$. I '+#$ t *n +n$ !$ u$n"$ &! +un,6 t $- ! +u(, *(( 5$ +utp&n"#$*!&n@ + t $&# ($n@t .
#eadloc3 #etection
C D
B
E
GF
, $
A
" 5
*
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 372/499
0ample .nput1
2 2 $6Db >DaaD6 bD>
0ample :utputIE;6DbD>DaD6
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 373/499
N+ *,*-! '*#?>up (*n@u*@$! (&?$a'e# 6L'M 6; M 6 *n,#M *#$ &,$(- u!$, t+ ,$ &n$6 &n * "+'p($t$(- t$ tu*( '+,$6 t $!t#u"tu#$! + ,+"u'$nt!. T +!$ (*n@u*@$! *#$ "+'p+!$, 5- t*@!6 +# *nn+t*t&+n!6 t *t *#$ u!$, t+ '*#? 5(+"?! + t$ t t $&$n,% &n +#,$#
• t+ !p$"& - t $ ,+"u'$nt !t#u"tu#$!> +# &n!t*n"$6 t $ front material (&?$ t $title6 t $authors 6 t $date 6 +# *chapter 6 &t &t! sections *n, para#raphs a
• t+ @&)$ t $' !+'$ !p$"&*( &nt$#p#$t*t&+n6 +# * p*#t&"u(*# +#'*tt&n@ &n +#'*t&+n = +# &n!t*n"$6 t+ !*- t,$!&@n*t$! *country 6 * profession 6 *kin# 6 +# t $ 5(+"? 'u!t 5$ p#&nt$, +ut &nitalic 6 +#boldface .
T*@! *#$ 0u!t +#,! (&?$ *(( t $ +t $#! t *t 5$(+n@ t+ t $ +#&@&n*( p(*&n t$ ta !+6 &t &! n$"$!!*#- t+ u!$ !+'$ ($ &"*(,&!t&n@u&! t +!$ !p$"&*( +#,! *nn+t*t&+n!%. A(!+6 $ n$$, !+'$ ($ &"*( "+n)$nt&+n t+ &,$nt& - t $ 5$@&nn&n@ *t$ t 5(+"? $ *nt t+ *nn+t*t$.
In t $ p#$!$nt "+nt$ t6 +u# '*#?>up (*n@u*@$ +((+ ! *n *pp#+*" !&'&(*# t+ t $; M 5*!$, (*n@u*@$!
• !p$"&*( " *#*"t$#! = ! u*#$
*n, "u#(-\ ]
5#*"?$t! = *#$ u!$, t+ &,$nt& - t $ +#,! t *t *#$ t*@ n*'$!a• t $ !*'$ t*@ n*'$ &! u!$, t+ !$tup 5(+"? 5+un,*#&$!6 *n, ($ &"*( ,$t*&( ,$ &n$! t $ +p$n&n@ *n, "(+!&n@ t*@
&! openin Dta , closin Dta *n, \openin Dclosin Dta ] .
P*&#$, t*@! *#$ $'p(+-$, t+ ,$ &n$ t $ ,+"u'$nt !t#u"tu#$6 &($ !&n@($ t*@! *#$ u!$, t+ @&)$ '$*n&n@ +# +#'*tt&nT*@ n*'$! +n$ ($tt$# +((+ $, 5- 8$#+ +# '+#$ ($tt$#! +# ,&@&t!% *#$ #$$6 &.$. n+t p#$)&+u!(- ,$ &n$,a t &! '$*n! t *'*#?>up (*n@u*@$ "*n " +!$ t $ n*'$! + t $ t*@! $ &(( $'p(+- t+ *nn+t*t$ &! ,+"u'$nt. J+ $)$#6 t+ 5$ *valid annotation &t'u!t 5$ &n "+n +#'&t- &t t $ +((+ &n@ #u($!
• *nopenin#-ta# 'u!t *( *-! *)$ * "+##$!p+n,&n@closin#-ta# a• * closin#-up 'u!t *( *-! *)$ * "+##$!p+n,&n@openin#-ta# a• p*&#$, t*@! '*- 5$ n$!t$, t+ *n- ($)$(6 + $)$# t $ (*!t +p$n&n@>t*@ 'u!t 5$ "(+!$, 5$ +#$ *n- $n"(+!&n@ t*@
$ t$#n*( 5(+"? "*n n+t 5$ "(+!$, 5$ +#$ *n &nt$#n*( +n$a•
*nopenin#-closin#-ta# "*n n+t *)$ +t $# t*@! &n!&,$a &n t *t "*!$6 t $ "+##$!p+n,&n@ 5(+"? + t$ t &(( *pp$*#"u#(- 5#*"?$t!.
G&)$n * !t#u"tu#$, ,+"u'$nt6 !upp+!$, t+ 5$ *nn+t*t$, *""+#,&n@(- t+ t $ '*#?>up (*n@u*@$ *5+)$ ,$!"#&5$,6 #&t$ *)*(&,*t$! &t6 t *t &! t *t )$#& &$! & t $ t*@! *#$ p#+p$#(-
InputThe input begins ?ith a single positive integer on a line by itsel7 indicating the number o7 cases 7ollo?ingJ each o7 them described belo?4 This line is 7ollo?ed by a blan3 lineJ and there is also a blan3 line bet?een t?o consecutive inputs4T $ &nput &! * p(*&n t$ t &($ &t t*@!6 +((+ &n@ t $ *5+)$ !t*t$, "+n)$nt&+n!. A!!u'$ t *t ($ &"*( "+n)$nt&+n! !p$"t #$$ t*@ t-p$! openin Dta , closin Dta *n, \openin Dclosin Dta ] % *#$ *( *-! "+'p(&$,.
OutputFor each caseJ the output must 7ollo? the description belo?4 The outputs o7 t?o consecutive cases ?ill be separated by ablan3 line4
T $ +utput "+n!&!t! +• 0u!t 1 (&n$ &t t $ +#,Rerror_ & +n$ + t $ #u($! + *5+)$ &! n+t +5!$#)$,6 '*?&n@ t $ &nput *n &n)*(&, *nn
,+"u'$nta
#ocument /alidator
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 374/499
• 2 (&!t! &t t $ t*@ n*'$! +un,6 &t +ut ,up(&"*t$! *n, &n t $ +#,$# t $- *pp$*# &n t $ ,+"u'$nt #+' t $ 5$@&nn&$n,%6 1 +#, p$# (&n$. T $ &#!t (&!t 5$@&n! &t t $ $*,&n@ (&n$Rstructural ta s_ 6 &($ t $ !$"+n, (&!t &(( 5$@&&t t $ $*,&n@ (&n$Rsemantic ta s . B(*n? (&n$! 5$t $$n t +!$ *#$ n+ *((+ $,.
S*'p($ &nput1
memode Comiss ao Cient fica do M97P depara 'odos os Concurrentes paradata \bold 2!!1&set&2"] datamensa empara =evem ter o m axiom cuidado na leitura dos enunciados& parapara =ese8amos a todos \dese8o Calma] e \dese8o >oa ;orte]Z paramensa emmemo
S&'p($ Output;'57C'756 '6 ;
memodeparadatamensa empara;EM6N'9C '6 ;bolddese8o
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 375/499
Fma" O$IMPIADAS DE PRO+RAMACIONINTER#A 4 8
In!ermedio
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 376/499
D$!*##+(($ un p#+@#*'* $n $( ($@u*0$ ,$ !u p#$ $#$n"&*6 p*#* u$ ($* un *#" &)+DATA.t t6 u$ "+nt$n,#_ un* '*t#&8 '*-+# + &@u*( * 2 ; 2. Su p#+@#*'* ,$5$#_ ($$# - ,$t$#'&n*# (* #ut* '_! "+#t* p*#* (($@*# ,$!,$ (* "*!&((* <6<% * (* '6n% $! ,$"&#$ t#$'+ !up$#&+# &8 u&$#,+ *!t* $( &n $#&+# ,$#$" + $n $!t$ "*!+ ,$!,$ $( 1 *!t* $E0.
1 2 3 4:1< 11 12
13 14 1 1:
En $!t$ $0$'p(+ (* #ut* '_! "+#t* $! 16263646 61261:INPUT
Un $0$'p(+ ,$( "+nt$n&,+ ,$ DATA.t t pu$,$ !$#
3 3
<2341:
BUJ7UJ!
02"#'$(&)
La ruta más corta entre 0 * ) es! 0, 2, ', &, )
Cota! 9ebe tomar en consideración que su programa debe reconocer cualquiermatriz ma*or o igual a 2 V 2. emplos! " V ", # V # etc.
P#+5($'* llllllll CAMINO MAS CORTOAut+# P#+ . H+! A. R+,#`@u$8 O#t$@*
D&'$n!&7n ,$ (*'*t#&8
C+nt$n&,+,$ (* '*t#&8
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 377/499
6mplemente un diamante basándose en el Jriángulo de 7ascal. l usuario entrará elnivel * su programa deberá generarlo. l diamante debe ser nivel " en adelante.
emplo!
ntre el nivel de su diamante! $
emplo 2!ntre el nivel de su diamante! (
Cota! u programa mostrará solo el dimante, no inclu*a los niveles.
P#+5($'* llllllll DIAMANTE DE PASCALAut+# P#+ . H+! A. R+,#`@u$8 O#t$@*
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 378/499
6mplemente un uego de Jic Jac Joe interactivo donde el usuario pueda ugar contrael código creado por usted. 9ebe tomar en consideración que se puede ganarhorizontal, vertical * diagonalmente. u programa deberá ser inteligente, es decir, lacomputadora debe programarse para ganar * ugar estratXgicamente. Co debe hacermeramente ugadas aleatorias.
P#+5($'* llllllll TIC TAC TOE 3D Int$#*"t&)+Aut+# P#+ . H+! A. R+,#`@u$8 O#t$@*
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 379/499
D$!*##+(($ un p#+@#*'* $n $( ($n@u*0$ ,$ !u p#$ $#$n"&*6 p*#* u$ ($* un *#" &)+ ((*'*,+ DATA.t t u$ "+nt&$n$ un"u*( u&$#* - un* 3 ; 3 "+n ,*t+! "+'+ (+! !&@u&$nt$!
INPUT
2
n/'$#+ $nt$#+ *#5&t#*#&+:3214 "+nt$n&,+ ,$ (* '*t#&8
Su p#+@#*'* ,$5$#_ n*)$@*# t+,*! (*! #ut*! p+!&5($! ,$!,$ $( $ t#$'+ !up$#&+# &8 u&$#,+ <6<% $n $!t$ "*!+6 *!t*&n $#&+# ,$#$" + n6 '% $n $!t$ "*!+. Su p#+@#*'* ,$5$#_ '+!t#*# t+,*! (*! #ut*! p+!&5($!sin repetir casillas6 (* #ut* ,$ (*!u'*t+#&* '_! "$#"*n* *( n/'$#+ u$ !$ p#+)$$ $n $( *#" &)+ 2 $n $!t$ "*!+%. L+! "*'&n+! !$ pu$,$n "+n!t#u&# '+)& n,+*##&5*6 *5*0+6 * (* ,$#$" * - * (* &8 u&$#,* nun"* $n ,&*@+n*(. N+ $! n$"$!*#&+ u$ !&@* $( !&@u&$nt$ +#,$n p
(*! )$#$,*!.OUTPUT
2 3 : 1 4 X 4 2 3 4 X 3 2 X 31 3 : 1 4 X 3 3 2 X 2 3 4 X 31 : 3 2 X 4< : 3 2 X 2 : 3 4 X 2
L* #ut* '_! "$#"* ,$ Q2 $! : 3 2 X 2
N+t*
L+! )*(+#$! ,$ (* '*t#&8 pu$,$n "+nt$n$# )*(+#$! n$@*t&)+!. D$ $ &!t&# #ut*! u$ p#+,u8"*n un '&!'+ #$!u(t*,+6 $( p#$!"+@$#_ * "+n)$n&$n"&* (* u$ u&$#* '+!t#*#.
P#+5($'* llllllll VEREDAS CON PROPÓSITOAut+# P#+ . H+! A. R+,#`@u$8 O#t$@*
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 380/499
Bac3groundOn$ ,*-6 *n *nt "*(($, A(&"$ "*'$ t+ *n MeM " $!!5+*#,. S $ *nt$, t+ @+ *#+un, *(( t $ @#&,!. S+ ! $ 5$@*n t+ *(? *(+" $!!5+*#, *""+#,&n@ t+ t &! *- -+u "*n *!!u'$ t *t $# !p$$, &! +n$ @#&, p$# !$"+n,%
At t $ &#!t !$"+n,6 S(&"$ *! !t*n,&n@ *t 16 1%. F&#!t(- ! $ $nt up t $ @#&,6 t $n * @#&, t+ t $ #&@ t6 * @#&, ,+ n$nt * @#&, t+ t $ #&@ t6 t $' t + @#&,! up *#,6 *n, t $n t + @#&,! t+ t $ ($ t &n * +#,6 t $ p*t *! (&?$ * !n*?$.
F+# $ *'p($6 $# &#!t 2 !$"+n,! $nt (&?$ t &!t $ nu'5$#! &n t $ @#&,! !t*n,! +# t $ t&'$ $n ! $ $nt &nt+ t $ @#&,!%
At t $ t !$"+n,6 ! $ *! *t 26 3%6 *n, *t 2<t !$"+n,6 ! $ *! *t 6 4%.Y+u# t*!? &! t+ ,$"&,$ $#$ ! $ *! *t * @&)$n t&'$.-+u "*n *!!u'$ t *t M &! (*#@$ $n+u@ %
.nputInput &($ &(( "+nt*&n !$)$#*( (&n$!6 *n, $*" (&n$ "+nt*&n! * nu'5$# N 1fX2e1< %6 &" !t*n,! +# t $ t&'$. T $ &($n,$, &t * (&n$ t *t "+nt*&n! * nu'5$# <.
:utputF+# $*" &nput !&tu*t&+n -+u ! +u(, p#&nt * (&n$ &t t + nu'5$#! 6 -%6 t $ "+(u'n *n, t $ #+ nu'5$#6 t $#$ 'u!t 5$ +n( 5$t $$n t $'.
0ample .nput2!2"!
0ample :utput2 3" $1 "
2 24 23 22 211< 11 12 13 2< 4
14 1 32 3 : 1 1 21 4 1: 1 1
1 2 3 4
Problem A4Ant on a Chessboard
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 381/499
Problem A( Bee -a%aM*0* &! * 5$$. S $ (&)$! &n * 5$$ &)$ &t t +u!*n,! + +t $# 5$$!. T &! 5$$ &)$ "+n!&!t! + '*n- $ *@+n*( +n$- "+'5t $ +n$- &! !t+#$, &n.But 5$$ M*0* *! p#+5($'. K&((& t+(, $# $#$ ! $ "*n '$$t &'6 5ut 5$"*u!$ K&((& &! * '*($ ,#+n$ *n, M*0* &! * $'*($t $- *)$ ,& $#$nt "++#,&n*t$ !-!t$'!.
J$(p M*0* t+ "+n)$#t K&((&d! !-!t$' t+ $#!. K#&t$ * p#+@#*' &" +# * @&)$n +n$- "+'5 nu'5$# @&)$! t $ "++#,&n*!-!t$'..nput 0peci7icationT $ &nput &($ "+nt*&n! +n$ +# '+#$ &nt$@$#! &" #$p#$!$nt K&((&d! nu'5$#!. E*" nu'5$# !t*n,! +n &t! + n &n * !$,&#$"t(- +((+ $, 5- * n$ (&n$. T $ +n$- "+'5 nu'5$#! *#$ ($!! t *n 1<< <<<.:utput 0peci7icationY+u ! +u(, +utput t $ "+##$!p+n,&n@ M*0 "++#,&n*t$! t+ &((&d! nu'5$#!6 $*" "++#,&n*t$ p*&# +n * !$p*#*t$ (&n$0ample .ntput123$"0ample :utput! !! 1D1 1D1 !! D1
-a%a s Coordinate 0ystem @illi s Coordinate 0ystemM*0* + + t$n (&$! ,&#$"t(- t+ * !p$"&*( +n$- "+'5*! (*&, *n *,)*n"$, t + ,&'$n!&+n*( @#&, +)$# t $+($ &)$.
K&((& + &! '+#$ (*8- *n, + t$n *(?! *#+un, 0u!tnu'5$#$, t $ "$((! "(+"? &!$ !t*#t&n@ #+' 1 &n t $'&,,($ + t $ &)$.
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 382/499
Fma" OI$IMPIADAS DE PRO+RAMACIONINTER#A 4 8
PRINCIPIANTES
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 383/499
B, $oKerca"e To 0pperca"e Con.er!
Trite a program that lets the user enter a string a character arra*. Jhe programshould then convert all the loFercase letters to uppercase or to Jitle 4ase. +6f acharacter is alread* uppercase, or is not a letter, it should be left alone. <int: 4onsultthe 8 446 chart in 8ppendi> 8. Cotice that the loFercase letters are represented b*the 8 466 codes )( thorough '22. 6f *ou subtract "2 from an* loFercase character:s
8 466 code, it Fill *ield the 8 466 code of the uppercase equivalent.
>ample!
Jhis program is difficult Y JA6 73BI38@ 6 9;;64ULJ Y Jhis 7rogram 6s9ifficult
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 384/499
2. Dri.erV" $icen"e E9am
Jhe local 9river:s License Bffice has asEed *ou to Frite a program that gradesthe Fritten portion of the driver:s license e>am. Jhe e>am has 20 multiplequestions. Aere are the correct ansFers!
'. N $. 8 ''. N '$. 42. 9 (. N '2. 4 '(. 4". 8 %. 8 '". 9 '%. N#. 8 ). 4 '#. 8 '). 9&. 4 '0. 9 '&. 9 20. 8
our program should store the correct ansFers shoFn above in an arra*. 6tshould asE the user to enter the student:s ansFers for each of the 20 questions, Fhichshould be stored in another arra*. 8fter the student:s ansFers have been entered, theprogram should displa* a message indicating Fhether a student passed or failed thee>am. +8 student must correctl* ansFer '& of the 20 questions to pass the e>am. 6tshould then displa* the total number of correctl* ansFered questions, and a listshoFing the questions numbers of the incorrectl* ansFered questions.
!nput validation: #nly accept t%e letters "4 ,4 C or as ans0ers .
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 385/499
3. $o!!er% Applica!ion
Trite a program that simulates a lotter*. Jhe program should have anarra* of five integers named lotter*, and should generate a randomnumber in the range of 0 through ) for each element in the arra*. Jhe usershould enter five digits Fhich should be stored in an integer arra* nameduser. Jhe program is to compare the corresponding elements in the tFoarra*s and Eeep account of the digits that match. ;or e>ample, thefolloFing shoFs the lotter* arra* and the user arra* Fith sample numbersstored in each. Jhere are tFo matching digits +elements 2 and # .
Lotter* arra*!
( # ) ' "
User arra*!
# 2 ) ( "
Jhe program should displa* the random numbers stored in the lotter*arra* and the number of digits matching digits. 6f all the digits match,displa* a message proclaiming the user as a grand prize Finner.
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 386/499
4. &Ca" Regi"!er Applica!ion' Use the numeric Ee*pad from the Securi!%Panel application to build a Ca" Regi"!er application. 6n addition to numbers,the cash register should include a decimal point Nutton. 8part from this numericoperation, there should be En!er Dele!e Clear and To!al Nuttons. ales ta>should be calculated on the amount purchased. Use a elect 4ase statement tocompute sales ta>. 8dd the ta> amount to the subtotal to calculate the total.9ispla* the ta> and total for the user. Use the folloFing salesGta> percentages,Fhich are based on the amount of mone* spent!
8mount under Z'00 [ &\ +.0& sales ta> 8mount betFeen Z'00 and Z&00 [ (.&\ +.0(& sales ta> 8mount above Z&00 [ '0\ +.'0 sales ta>
*% Define e.en! andler" for ! e numeric #u!!on" and decimal poin! in! e ke%pad, 4reate event handlers for each of these Nutton:s 4licEevents. Aave each event handler concatenate the proper value to theJe>tNo> at the top of the ;orm.
5% Define an e.en! andler for ! e En!er #u!!onV" Click e.en!, 4reate anevent handler for this Nutton:s 4licE event. Aave this event handler addthe current amount to the subtotal and displa* the neF subtotal.
"% Define an e.en! andler for ! e To!al #u!!onV" Click e.en!, 4reate anevent handler for this Nutton:s 4licE event. Aave this event handler usethe subtotal to compute the ta> amount.
,% Define an e.en! andler for ! e Clear #u!!onV" Click e.en!, 4reate anevent handler for this Nutton:s 4licE event. Aave this event handler clearthe user input and displa* the value Z0.00 for the subtotal, sales ta> andtotal.
$% Define an e.en! andler for ! e Dele!e #u!!onV" Click e.en!, 4reate anevent handler for this Nutton:s 4licE event. Aave this event handler clearonl* the data in the Je>tNo>.
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 387/499
Universidad Interamericana de Puerto RicoRecinto de Bayamón
CO-;2/2NCI"S 2 ;?O<?"-"CI@ND
23pertos
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 388/499
Un&)$#!&,*, Int$#*'$#&"*n* ,$ Pu$#t+ R&"+u&nt*! O(&'p&*,*! ,$ P#+@#*'*"&7n
!N" R $% &''
CATEGORrA DE E;PERTOS
In!t#u""&+n$! @$n$#*($!
T+,+! (+! p#+5($'*! ,$ $!t* "*t$@+#`* !$#_n &nt$#*"t&)+! -b+ "+n *#" &)+! $ t$#n+!. S$ ut&(&8Stu,&+. N$t p*#* #$!+()$# (+! '&!'+!. D$5$n $nt#$@*#!$ $n ,&!"+ t*n p#+nt+ "+'+ (+ *-*! t$#'&n
PROBLEMA 1
Decimal)#inar%
A !&'p($ '$t +, +# "+n)$#t&n@ 5*!$ 1< ,$"&'*(! t+ 5*!$ 2 &! t+ #$p$*t$,(- 'u(t&p(- 5- 2 *n, t*?$ t $ #$!u(t. F+# $ *'p($6 t $ "+n)$#!&+n + .14<:2 5*!$ t+ .<<1<<1 5*!$ 2 &! ! + n 5- t $ +((+ &n@ " *
.14<:2 <.2 12 XZ<
.2 12 <. :2 XZ<
. :2 1.12 XZ1
.12 <.2 XZ<
.2 <. XZ<
. 1 XZ1
T &! p#+"$!! t$#'&n*t$! $n t $ ,$"&'*( p+#t&+n + t $ p#+,u"t &! <.
T $#$ &(( 5$ nu'5$#! &nput6 $*" ($!! t *n 1.<. C+n)$#t $*" &nput t+ 5&n*#- *n, p#&nt t $ &#!tt $ 5*!$ 2 nu'5$#6 +# $ $# & t $ p#+"$!! t$#'&n*t$! 5$ +#$ t *t. D+ n+t p#&nt *n- ,&@&t! t+ t $ ($[,$"&'*( p+&nt.\
0ample .nput(
L&n$ 1 .14<:2L&n$ 2 .111
0ample :utput(
Output 1 .<<1<<1
Output 2 .<<<111<<<1
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 389/499
Programming Problem #
Test #ata .nput(
1 .1<2 .43 .24 .12 .<<1
Test #ata :utput(
1 .<<<11<1<112 .<111<<11<<3 .<14 .<<1 .<<<<<<<<<1
PR:B!$-A '
Time CardH$nn- 0u!t !t*#t$, +#? *! * p#+@#*''$# +# Hu!t&n$d! H*)* K+#?! +p. S $ &! p*&, ^1< *n +u#6 $ "$pt&+n!. S $ $*#n! *n $ t#* ^1. < *n +u# +# *n- p*#t + * ,*- $#$ ! $ +#?! '+#$ t *n +u#!6 *n$ t#* ^2. < *n +u# +# +u#! 5$-+n, 4< &n *n- +n$ $$?. A(!+6 ! $ $*#n! * 2 x 5+nu! +# +#?&n@ S*tu#,*- *n, Sun,*- *#$ "+'put$, 5*!$, +n t $ +u#! +#?$, t +!$ ,*-!a t $- *#$ n+t u!$, t+ "*("u(*t$ *n- 5+nu! +# +#?&n@ '+#$ t *n 4< +u#! &n * $$?.
Y+ud(( 5$ @&)$n t $ nu'5$# + +u#! H$nn- +#?$, $*" ,*- &n * $$? Sun,*-6 M+n,*-6 6 S*tu#,*-%-+u n$$, t+ "+'put$ $# !*(*#- +# t $ $$?. T $ &nput &(( 5$ p+!&t&)$ &nt$@$#!6 ($!! t *n +# $ u*+utput 'u!t 5$ +#'*tt$, &t * ,+((*# !&@n *n, #+un,$, t+ t $ n$*#$!t p$nn-. F+# $ *'p($6 [^2\ *n,[^2.13::::\ *#$ #+n@ *n! $#!a t $ "+##$"t )$#!&+n! *#$ [ ̂ 2.<<\ *n, [^2.14\6 #$!p$"t&)$(-. T $#$ '* 5$ *n- $'5$,,$, !p*"$! &n -+u# *n! $#!. T $#$ &(( 5$ !$t! + ,*t*.
0ample .nput(
L&n$ 1 <6 6 6 6 1<6 :6 <L&n$ 2 46 <6 <6 <6 <6 :6 <
S*'p($ Output
Output 1 ^4<3.<<Output 2 ^12<.<<
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 390/499
PROBLEMA 3
Mul!iplicación Ru"aEn $( !&@(+ p*!*,+ $n Ru!&*6 (+! "*'p$!&n+! !$ !$#)`*n ,$ un &n@$n&+!+ ' t+,+ ,$
'u(t&p(&"*"&7n p*#* $( u$ !7(+ n$"$!&t*5*n !*5$# $n"+nt#*# $( ,+5($ - (* '&t*, ,$ un n/'$"+'+ (* $($'$nt*( +p$#*"&7n ,$ !u'*#. C+n $!t$ !&!t$'* *5`* u$ +#'*# ,+! "+(u'n*!$n"*5$8*,*! p+# (*! "& #*! u$ !$ &5*n * 'u(t&p(&"*#.
E( ' t+,+ +p$#* $n (* !&@u&$nt$ +#'*
E0$'p(+ 'u(t&p(` u$!$ p+# 3
S$ !*"* !u"$!&)*'$nt$ (* '&t*, * (+! n/'$#+! !&tu*,+! $n (* "+(u'n* ,$ (* &8 u&$#,* !&t+'*# $n "u$nt* (+! #$!&,u+!%6 - $( ,+5($ * (+! ,$ (* "+(u'n* ,$#$" *. S$ "+nt&n/* $!t* +p$*!t* u$ (* "+(u'n* &8 u&$#,* !$ #$,u8"* * (* un&,*,.
; 34 ;
24 ; 1 :
12 ; 312
: ; :24
3 ; 124
1 ; 24 :
S$ t*" *n t+,*! (*! "& #*! p*#$! u$ &@u#$n $n (* "+(u'n* &8 u&$#,* - p+# "+n!&@"& #*! "+##$!p+n,&$nt$! $n (* "+(u'n* ,$#$" *.
; 3
4 ;
24
; 1 :
1
2
; 312
: ; :243 ; 1241 ; 24 :
F&n*('$nt$ !$ !u'*n (*! "& #*! u$ u$,*n $n (* "+(u'n* ,$#$" *. E( t+t*( ,$ (* !u'* $! $#$!u(t*,+. 3 124 24 :X3 3
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 391/499
PROBLEMA 4
Her!ical 5i"!ogram
E!"#&5$ un p#+@#*'* u$ *"$pt$ ,`@&t+! <> % "+'+ Input. D$ "+'+ #$!u(t*,+ $( &)$#t&"*( #$p#$!$nt*t&)+ ,$ "*,* ,`@&t+. C*("u(* t*'5& n (* !u'* ,$ t+,+! (+! ,`@&t+!6 $( p
,* "+'+ #$!u(t*,+ (* (&!t* ,$ (+! n/'$#+! p+# ,$5*0+ ,$( p#+'$,&+ !&n #$p$t&# - (* (&!t* ,$ ( p+# ,$5*0+ ,$( p#+'$,&+ !&n #$p$t&# - (* (&!t* ,$ (+! n/'$#+! p+# $n"&'* ,$( p#+'$,&+ !&n
V$#& &"* tu p#+@#*'* "+n $!t$ !$t ,$ 13 ,`@&t+!.16 626 6:6 61636 6 6 6 6<
E0$'p(+ ,$ Input
Enter a Number : 12Enter 12 di its:1G!G2G9G6G!G1G3G!G5G!G9
E0$'p(+ ,$ Output
. .
. . .
... ... .
<1234 :
L* !u'* $! :4 E( p#+'$,&+ $! .3L+! n/'$#+! p+# ,$5*0+ !+n 16263L+! n/'$#+! p+# $n"&'* :6 6
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 392/499
1234 : <1234 : <1234 : <1234 : <1234 : <1234 : <1234 : <1234 : <
1121123211234321123 43211234 : 43211234 : : 43211234 : : 43211234 : : 43211234 : : 43211234 : : 43211234 : 43211234 43211234321
123211211
XXXX En, + +utput ,*t*
P#+5($'*
V&#u! D$t$"t&+n
K $n $ *'&n&n@ * &($6 * "$#t*&n )&#u! !"*nn$# (++?! +#6 *'+n@ +t $# t &n@!6 +#, [)&#u!\ &n t $ &($. F+# $ *'p($6 t $ (&n$.
*512^)&#u!23
>>>>
*pp$*#&n@ &n !+'$ &($ +u(, 5$ '*#?$, *! !u!p$"t6 *! &t "+nt*&n! *n +""u##$n"$ +[)&#u!\. It &! !* $#6 + $)$#6 t+ *(!+ (++? +# *t *#$ "*(($, [!"*tt$#$, +""u##$n"$!\ + t $ !
[)&#u!\. F+# $ *'p($6 t $ (&n$.*(&#u!)2)#&&#"^u u!
> > > >
"+nt*&n! * [!"*tt$#$, +""u##$n"$\ + t $ !t#&n@ [)&#u!\6 &" &! &n,&"*t$, 5- t $ u" *#*"t$#!. N+t$ t *t $)$n &n * [!"*tt$#$, +""u##$n"$\ + t $ +#, t $ +#,$# + t $ ($tt$#! #$'*!*'$ *! &n t $ "+##$"t(- !p$(($, +#, [)&#u!\.
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 393/499
Y+u# t*!? &n t+ #&t$ * p#+@#*' t *t #$*,! $*" (&n$ &n * t$ t &($ "*(($, TEST.DAT+utput! t $ (&n$ nu'5$# + $)$#- (&n$ + t$ t &" "+nt*&n! $&t $# * ,&#$"t +""u##$n"$ + t[)&#u!\6 +# * [!"*tt$#$, +""u##$n"$\ + t $ !t#&n@ [)&#u!\6 *! ,$!"#&5$, *5+)$. T $ &#!t ("+nt*&n! 0u!t t $ nu'5$# + (&n$! + t$ t t+ +((+ . T $ (&n$! + t$ t &n t $ &($ #+' (&n$ 2 ++n *#, *)$ [(&n$ nu'5$#!\ !t*#t&n@ *t 1.
XXXX S*'p($ &nput ,*t* #+' VIRUS1.DAT
4,! ,)& , ,# ))))&#u!23$4y 1))& ,!"#32uu2!!xx@ !,XXXXEn, + &nput ,*t*bSt*# + "+##$!p+n,&n@ +utput ,*t*XXXXXXXXXXXXXXXXXXXX
23XXXXEn, + +utput ,*t*
X
XXXXS*'p($ &nput ,*t* #+' VIRUS2.DATXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
:It&!)$#-&n)&@+#*t&n@t+#un*#+un,t $!?-!"#*p$#.T &! (&n$ ,+$! n+t "+nt*&n t $ )e&e#eue! !t#&n@. O# ,+$! &th% ex V y^y&e%e% R < ue%e%eS N+ &!t $t&'$ +#*(( *"?$#!*n,))))&&&###uuu!!! #&t$#!t+"$*!$*n,,$!&!tWF*0(")0&+#- $+p# *)?* -&$!,0)+$ 5@P&#+ut#@5! +@u+ @n?tn n!? ? ? ? ? 5 !??( $&?5'*, @&-$ t
XXXXEn, + &nput ,*t*bSt*#t + "+##$!p+n,&n@ +utput ,*t*XXXXXXXXXXXXXXXXXXXXX124XXXXEn, + +utput ,*t*
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 394/499
Universidad Interamericana de Puerto RicoRecinto de Bayamón
CO-;2/2NCI"S 2 ;?O<?"-"CI@ND
;rincipiantes
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 395/499
=niversidad !nteramericana de Puerto >icou&nt*! O(&'p&*,*! ,$ P#+@#*'*"&7nINTERBAY 2<<4
CAT$9:R A0 #$ PR.NC.P.ANT$0
In!t#u""&+n$! @$n$#*($!
T+,+! p#+5($'*! ,$ $!t* "*t$@+#`* !$#_n &nt$#*"t&)+! -b+ "+n *#" &)+! $ t$#n+!. SV&!u*( Stu,&+ .N$t p*#* #$!+()$# (+! '&!'+!. D$5$n $nt#$@*#!$ $n ,&!"+ t*n p#+nt+ "+'+t$#'&n*,+.
PROBLEMA 1
&Ca" Regi"!er Applica!ion'U!$ t $ nu'$#&" ?$-p*, #+' t $ S$"u#&t- P*n$( *pp(&"*t&+n t+ 5u&(, * C*! R$@&
*pp(&"*t&+n. In *,,&"t&+n t+ nu'5$#!6 t $ "*! #$@&!t$# ! +u(, &n"(u,$ * ,$"&'*( p+&nt B#+' t &! nu'$#&" +p$#*t&+n6 t $#$ ! +u(, 5$ Ent$#6 D$($t$6 C($*# *n, T+t*( Butt+n!. S*(
5$ "*("u(*t$, +n t $ *'+unt pu#" *!$,. U!$ * S$($"t C*!$ !t*t$'$nt t+ "+'put$ !*($! t* . A,, t $t* *'+unt t+ t $ !u5t+t*( t+ "*("u(*t$ t $ t+t*(. D&!p(*- t $ t* *n, t+t*( +# t $ u!$#. U!$ t $+((+ &n@ !*($>t* p$#"$nt*@$!6 &" *#$ 5*!$, +n t $ *'+unt + '+n$- !p$nt
A'+unt un,$# ^1<<X x .< % !*($! t*A'+unt 5$t $$n ^1<< *n, ^ <<X . x .< % !*($! t*A'+unt *5+)$ ^ << X 1<x .1<% !*($! t*
D$ &n$ $)$nt *n,($#! +# t $ nu'$#&" Butt+n! *n, ,$"&'*( p+&nt &n t $ ?$-p*,. C#$**n,($#! +# $*" + t $!$ Butt+nd! C(&"? $)$nt!. J*)$ $*" $)$nt! *n,($# "+n"*t$n*t$ t $ p#+)*(u$ t+ t $ T$ tB+ *t t $ t+p + t $ F+#'.
D$ &n$ *n $)$nt *n,($# +# t $ Ent$# Butt+nd! C(&"? $)$nt C#$*t$ *n $)$nt *n,($# Butt+nd! C(&"? $)$nt. J*)$ t &! $)$nt *n,($# *,, t $ "u##$nt *'+unt t+ t $ !u5t+t*( *n, ,&!p(*n$ !u5t+t*(.
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 396/499
D$ &n$ *n $)$nt *n,($# +# t $ T+t*( Butt+nd! C(&"? $)$nt C#$*t$ *n $)$nt *n,($# Butt+nd! C(&"? $)$nt. J*)$ t &! $)$nt *n,($# u!$ t $ !u5t+t*( t+ "+'put$ t $ t* *'+unt.
D$ &n$ *n $)$nt *n,($# +# t $ C($*# Butt+nd! C(&"? $)$nt C#$*t$ *n $)$nt *n,($# Butt+nd! C(&"? $)$nt. J*)$ t &! $)$nt *n,($# "($*t t $ u!$# &nput *n, ,&!p(*- *n, ,&!p(*- t $^<.<< +# t $ !u5t+t*(6 !*($! t* *n, t+t*(.
D$ &n$ *n $)$nt *n,($# +# t $ D$($t$ Butt+nd! C(&"? $)$nt C#$*t$ *n $)$nt *n,($#Butt+nd! C(&"? $)$nt. J*)$ t &! $)$nt *n,($# "($*# +n(- t $ ,*t* &n t $ T$ tB+ .
PROBLEMA 2
&Pre"en! Halue Calcula!or Applica!ion'A 5*n? *nt! t+ ! + &t! "u!t+'$#! + 'u" t $- +u(, n$$, t+ &n)$!t t+ *" &$)$ *
!p$"& &$, &n*n"&*( @+*( utu#$ )*(u$% &n 61<61<61 62<62 +# 3< -$*#!. U!$#! 'u!t p&n*n"&*( @+*( t $ *'+unt + '+n$- ,$!&#$, * t$# t $ !p$"& &$, nu'5$# + -$*#! *! $(*p!$,%&nt$#$!t #*t$ *n, t $ ($n@t + t $ &n)$!t'$nt &n -$*#!. C#$*t$ *n *pp(&"*t&+n t *t "*("u(*,&!p(*-! t $ p#&n"&p*( &n&t&*( *'+unt t+ &n)$!t% n$$,$, t+ *" &$)$ t $ u!$#d! &n*n"&**pp(&"*t&+n ! +u(, *((+ t $ u!$# t+ &n)$!t '+n$- +# 6 1<61 62<62 +# 3< -$*#!. F+# $ *'p"u!t+'$# *nt! t+ #$*" t $ &n*n"&*( @+*( + ^1 6<<< +)$# * p$#&+, + -$*#! $n t $ &nt$&! :.: x6 t $ "u!t+'$# +u(, n$$, t+ &n)$!t ^1<6 :. :.
A,,&n@ t $ nu'$#&"UpD+ n "+nt#+( P(*"$ *n, !&8$ t $ nu'$#&"UpD+ n !+ t *t & +(GUI D$!&@n Gu&,$(&n$!. S$t t $ nu'$#&"pD+ n "+nt#+(d! N*'$ p#+p$#t- t+ upY$*#. S$tnu'$#&"UpD+ n "+nt#+( t+ *((+ +n(- 'u(t&p($! + &)$ +# t $ nu'5$# + -$*#!. A(!+6*((+ tt+ !$($"t +n(- * ,u#*t&+n t *t &! &n t $ !p$"& &$, #*n@$ + )*(u$.
A,,&n@ * 'u(t&(&n$ T$ tB+ A,, * T$ tB+ t+ t $ F+#' 5$(+ t $ Nu'$#&"UpD+ n "+nt#C *n@$ t $ !&8$ t+ 2 26 *n, p+!&t&+n t $ T$ tB+ +n t $ B+ t+ ,&!p(*- 'u(t&p($ (&n$! *n)$#t&"*( !"#+((5*#. A(!+ $n!u#$ t *t t $ u!$# "*nn+t '+,& - t $ t$ t &n t $ T$ tB+ .
A,,&n@ * C(&"? $)$nt *n,($# *n, *,,&n@ "+,$ A,, * "(&"? $)$nt *n,($# +# t $ C*("uB+tt+n. On"$ &n "+,$ t+ t $ *pp(&"*t&+n !u" t *t6 $n t $ C*("u(*t$ Butt+n &! "(&"?$,6 tT$ tB+ ,&!p(*-! t $ n$"$!!*#- p#&n"&p*( +# $*" &)$>-$*# &nt$#)*( u!$ t $ +((+ &n@ )$ p#$!$nt>)*(u$ "*("u(*t&+n +#'u(*
PX*b 1 #%n
K $#$ p &! t $ *'+unt n$$,$, t+ *" &$)$ t $ utu#$ )*(u$r &! t $ *nnu*( &nt$#$!t #*t$ +# $ *'p($6 .< &! $ u&)*($nt t+ x%n &! t $ nu'5$# + -$*#!a &! t $ utu#$>)*(u$ *'+unt
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 397/499
PROBLEMA 3
&Arra%'
U!$ * +n$>,&'$n!&+n*( *##*- t+ !+()$ t $ +((+ &n@ p#+5($' A "+'p*n- p*-! &t! !*($+n * "+''&!!&+n 5*!&!. T $ !*($!p$+p($ #$"$&)$ ^2<< p$# $$?6 p(u! x + t $&# @#+!! !*
$$?. F+# $ *'p($6 * !*($!p$#!+n + @#+!!$! ^ <<< &n !*($! &n * $$? #$"$&)$! ^2<< p(u!^ <<<6 +# * t+t*( + ^: <. K#&t$ * p#+@#*' u!&n@ *n *##*- + "+unt$#!% t *t ,$t$#'&n$!t $ !*($!p$+p($ $*#n$, !*(*#&$! &n $*" + t $ +((+ &n@ #*n@$! *!!u'$ t *t $*" !*($!p$#!&! t#un"*t$, t+ *n &nt$@$# *'+unt%
^2<<>^2^3<<>^3^4<<>^4^ <<>^^:<<>^:^ <<>^^ <<>^^ <<>^^1<<< *n, +)$#
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 398/499
PROBLEMA 4
&Crea!e and Main!ain Telep one Direc!orie"'
K#&t$ * p#+@#*' t+ "#$*t$ *n, '*&nt*&n t$($p +n$ ,&#$"t+#&$!. E*" ,&#$"t+#- &
!$p*#*t$ !$ u$nt&*( &($. T $ +((+ &n@ 5utt+n! ! +u(, 5$ *)*&(*5($
S$($"t * ,&#$"t+#- t+ *""$!!. A (&!t + ,&#$"t+#&$! t *t *)$ 5$$n "#$*t$, ! +u(, 5$ !!$p*#*t$ !$ u$nt&*( &($. K $n * #$ u$!t &! '*,$ t+ +p$n * ,&#$"t+#-6 t $ (&!t + *)*&(*5($! +u(, 5$ ,&!p(*-$, *! p*#t + *n InputB+ p#+'pt #$ u$!t&n@ t $ n*'$ n+ (&!t$,6 t $ ,$!&#$ t"#$*t$ * n$ ,&#$"t+#- "#$*t$, *n, *,,$, t+ t $ (&!t + $ &!t&n@ ,&#$"t+#&$!.
A,, n*'$ *n, p +n$ nu'5$# *! @&)$n &n t $ t$ t 5+ $!% t+ t $ $n, + t $ "u##$nt ,&#$"tD$($t$ n*'$ *! @&)$n &n t $ t$ t 5+ % #+' t $ "u##$nt ,&#$"t+#-S+#t t $ "u##$nt ,&#$"t+#- &nt+ n*'$ +#,$#.P#&nt +ut t $ n*'$! *n, p +n$ nu'5$#! "+nt*&n$, &n t $ "u##$nt ,&#$"t+#-T$#'&n*t$ t $ p#+@#*'
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 399/499
Universidad Interamericana de Puerto RicoRecinto de Bayamón
CO-;2/2NCI"S 2 ;?O<?"-"CI@N9
23pertos
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 400/499
!nter?ay -ay &,J 'KK=
$5pert
Program &
6eig !ed #inar% Tree"
K *t +u(, *n ACSL A((>St*# C+nt$!t 5$ &t +ut * 5&n*#- !$*#" t#$$ p#+@#*'h Yup6 &t 0u!t +u(A((>St*# C+nt$!t6 !+ $#$ $ @+
In * 5&n*#- !$*#" t#$$6 t $ n+,$! t *t *#$ n$*# t $ t+p + t $ t#$$ *#$ *!t$# t+ &n, t *t t $ n+,$! *t tIt +u(, 5$ n&"$ t+ *)$ t $ n+,$! t *t &(( 5$ (++?$, +# #$ u$nt(- t+ *pp$*# *t t $ t+p + t $ t#$$.
T $ &nput &n t &! p#+@#*' &! * !t#&n@. I@n+#$ $)$#-t &n@ &n t $ !t#&n@ 5ut t $ ($tt$#! + t $upp$#"*!$ ($tt$#! t+ (+ $#"*!$ +# )&"$ )$#!*%a t $ n+,$! &n t $ t#$$ &(( 5$ ($tt$#!.
0tep &. Bu&(, * 5&n*#- !$*#" t#$$ #+' t $ &nput. I -+u $n"+unt$# * ($tt$# t *t &! *(#$*,- &n t $ t# 5u&(,&n@ t $ t#$$. D$($t$ #+' t $ &nput t $ p#$)&+u! +""u##$n"$ + t &! ,up(&"*t$ ($tt$#6 *n, " *!+ t $ ,up(&"*t$ ($tt$# 0u!t $n"+unt$#$, &! n+ &#!t &n t $ &nput. R$5u&(, t $ t#$$ #+' !"#*t" 6 !tn$ t t&'$ t *t * ,up(&"*t$ ($tt$# &! +un, &n t $ '+,& &$, &nput%6 #$*##*n@&n@ t $ &nput6 *n, !&nput &! [CENTER\6 -+ud, 5u&(, * t#$$ &t C E N T6 !t+p 5$"*u!$ t $#$d! * ,up(&"*t$ E6 #$*##* 5$ E C N T *n, "+nt&nu$ 5u&(,&n@ t $ t#$$. T $ ?$-! &n t $ &n*( t#$$ +u(, 5$ E C N T R6 &n t &
0tep '4 A t$# t $ t#$$ &! 5u&(t6 @+ t #+u@ t $ ($tt$#! &n t $ +#&@&n*( &nput !t#&n@ *n, !$*#"t#$$. K $n -+u &n, t $ n+,$6 #$"+#, &t! ,$pt . T $ !u' + t $ ,$pt ! + t $ n+,$! +# *(( t $ &nput &n p#+p+#t&+n*( t+ t $ t&'$ n$$,$, t+ !$*#" &n t $ t#$$.
F+# $ *'p($6 "+n!&,$# t $ &nput [J+u!t+n6 T$ *!\ A !t*n,*#, 5&n*#- !$*#" t#$$ &@n+#&n@ ,up(&t#$$ *t t $ ($ ta t $ $&@ t$, t#$$ t *t -+ud(( 5u&(, &n t $ p#+@#*' &! *t t $ #&@ t. T $ &n*( t&'$ t$&@ t$, t#$$ *! #$5u&(t *! $n &t p#+"$!!$, t $ &n*( S. At t *t p+&nt6 t $ ($tt$#! $#$ &n!$#t$, S T O J U N E ; A.
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 401/499
T $ !t*n,*#, 5&n*#- !$*#" t#$$ ($ t% *! * processin# time + 2: < 1 2 3 4 1 2 4 1 3 2 3%6 $#$*! t $$&@ t$, )$#!&+n #&@ t% *! * processin# time + 21 2 1 2 < 1 1 3 1 3 3 4 <%.
0ample #ata 2 !$t! + ,*t*a t $ t$!t ,*t* *! 1< !$t! + ,*t*%
.nput :utputJ+u!t+n6 T$ *! 21
A'$#&"*n C+'put$#S"&$n"$ L$*@u$ ACSL% :
Program @eighted Binary Trees
.nput :utput
B&n*#- !$*#"t#$$!
34
F#$$,+' +!p$$"
2
D#. H-?$(( *n,M#. J-,$
4<
S*n F#*n"&!"+ 22
C*(& +#n&* 2<S*n F#*n"&!"+6
C*(& +#n&*4
t+ +' &t '*-"+n"$#n
3:
P#$!&,$ntK&((&*' C(&nt+n
4
V&"$ P#$!&,$ntA( G+#$
4<
; <
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 402/499
.nterBay
-ay &,J 'KK=
$5pert
Program '
TriangleG&)$n t #$$ (&n$! t *t &nt$#!$"t !u" t *t t $ &nt$#!$"t&+n p+&nt! +#' * t#&*n@($6 &n, t $ p$#&
T+ '*?$ t $ &nput $*!-6 $*" (&n$ &(( 5$ !p$"& &$, 5- t + p+&nt! #+' *'+n@ t $ +((+ &n@ 12 p+&
A <6<% B 263% C >26 %D >26 >4% E 16 >2% F 46 1%G >46 1% J >26 <% I <6 >:%H 36 >4% 6 % L 36<%
0ample #ata !$t! + ,*t*a t $ t$!t ,*t* *! 1< !$t! + ,*t*%
Input OutputDL6
GJ6 JF13. <
JD6EH6 FI
23. 2
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 403/499
Program 'J Triangle
.nput :utputAG6
GC6 CA13. <4
HL6 EH6EL
.: :
BC6L6 AE
22. <
JL6BJ6 LB
13.1:22
EH6 HL6EL
.: :
ID6 FH6BD
3 .3 421
JB6BL6 LJ
13.1:22
LE6 HE6 LH
.: :
BF6 IL6G
11. 2<1
AL6HL6 AH
12.<<<<<
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 404/499
.nterBay
-ay &,J 'KK=
$5pert
Program =
Ano! er #alancing Ac!
U!u*((- $n -+u 5u&(, * 5&n*#- !$*#" t#$$6 -+u *,, $*" ?$- t+ t $ t#$$ *! t $ ?$- &! $n"+unt$#$, &n!t#$*'. F+# $ *'p($6 t $ 5&n*#- !$*#" t#$$ 5u&(t #+' t $ ($tt$#! A M E R I C A !t*#t&n@ &t t $ A&t t $ &n*( A (++?! *! +((+ !
I -+u ?n$ *(( + t $ ?$-! &n *,)*n"$6 -+u '&@ t " ++!$ t+ *,, t $' &n t $ +#,$# E A A C M I R t+ +#' * p$# $"t(- 5*(*n"$, t#$$. T $#$ *#$ +t $# +#,$#! t *t *(!+ -&$(, * 5*(*n"$, t#$$.% J+ $)$#6 ,$t$#'&nt+ &n!$#t t $ ?$-! #$ u&#$! t *t -+u !+#t t $ ?$-!6 * t&'$>"+n!u'&n@ p#+p+!&t&+n. T &! p#+5($' $'$t +, t *t ,+$!ndt &n)+()$ !+#t&n@.
In t &! p#+@#*'6 -+ud(( ?$$p * 2>" *#*"t$# (++?>* $*, 5u $#. T *t &!6 &n *,,&t&+n t+ ?n+ &n@*,,&n@6 -+u *(!+ *)$ *""$!! t+ t $ n$ t t + " *#*"t$#!. O t $ t #$$ " *#*"t$#!6 -+u ! +u(, &n!$#t t $ +n$. F+# $ *'p($6 &t t $ ($tt$#! A M E R I C A6 -+u !t*#t + (++?&n@ *t A M E6 *n, -+ud, &n!$##++t. N+ 6 -+u *)$ A *n, M &n -+u# 5u $#6 *n, -+u !"*n t $ R. O t $!$ t #$$ ($tt$#!6 -+ud, *!! t $ Y+ud, *,, t $ I *n, t $n t $ C. F&n*((-6 $n -+u !"*n t $ &n*( A6 -+u *)$ A *n, R *(#$*,- &n t $ "*"Y+u &n!$#t *n A t $ '$,&*n ($tt$#%6 *n, t $n -+u *#$ ($ t &t A *n, R. In!$#t t $ !'*(($# + t $ t + &&n*( t#$$ (++?! *! +((+ !
In t &! p#+5($'6 -+u n$$, t+ "+'p*#$ t $ ! *p$ + * !t*n,*#, 5&n*#- !$*#" t#$$ &t +n$ 5u&(t u!&n@" *#*"t$# (++?>* $*, 5u $#. T $ &nput &(( 5$ 1< !$t! + ,*t*. E*" !$t &(( "+n!&!t + * !t#&n@ S.S6 &@n+#$ $)$#-t &n@ 5ut t $ ($tt$#! + t $ *(p *5$ta upp$#"*!$ *n, (+ $#"*!$ *#$ t $ !*'$. F+# $*
I
I
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 405/499
#$p+#t + 'u" t $ &nt$#n*( p*t ($n@t ,$"#$*!$! u!&n@ * 2>" *#*"t$# (++?>* $*, 5u $#. I t $ &n($n@t &n"#$*!$!6 -+ud(( #$p+#t * n$@*t&)$ nu'5$#.% F+# $ *'p($6 AMERICA *! *n &nt$#n*( pu!&n@ * "+n)$nt&+n*( 5&n*#- !$*#" t#$$a &t t $ 5u $#6 t $ p*t ($n@t ,$"#$*!$! 5- 1 t+ 11.
0ample .nput(L&n$ 1 A'$#&"*L&n$ 2 N+#t C*#+(&n*
0ample :utput(Output 1 1Output 2 >4
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 406/499
.nterBay
-ay &,J 'KK=
$5pert
Program +
ACS$1ip
In +#,$# +# * 5u!&n$!! t+ @$t t $ 5$!t p#&"$ #+' t $ Un&t$, St*t$! P+!t*( S$#)&"$6 t $ 5u!&n$!! 'u'*&( t+ t $ p+!t + &"$ &n p#$>!+#t$, 5un,($!. T $ 5un,($! 'u!t 5$ +#'$, *""+#,&n@ t+ t $ +((+ &n@&n t $ +((+ &n@ +#,$#
1. Bun,($ 1< +# '+#$ p&$"$! + '*&( &t t $ !*'$ ,&@&t 8&p "+,$ *n, p(*"$ * [D\ !t&"?$# + p&$"$.
2. Bun,($ 1< +# '+#$ p&$"$! &t t $ !*'$ &#!t 3 ,&@&t! + t $&# 8&p "+,$ *n, p(*"$ * [3\ !tt+p p&$"$.
3. Bun,($ 1< +# '+#$ p&$"$! t+ t $ !*'$ A#$* D&!t#&5ut&+n C$nt$# ADC% *n, p(*"$ *n [t $ t+p p&$"$. An ADC &! * *- t+ @#+up t+@$t $# )*#&+u! 8&p "+,$!. T $ +((+ &n@ ADC t *t &! u!$, +# 8&p "+,$! +!$ &#!t 3 ,&@&t! 5$@&n *! &n,&"*t$,. F+# $ *'p($6 [<2 \ &! u!$, +# 8&p "+,$! t *t 5$@&n <2<6 <236 <246 <2 6 6 <2 .
4. 1< <<46 1< >1<. 11 << 6 11 6 11 >11:. 1<: <<:><<. 11< <1<><1. <21 <1 6 <1 6 <216 <226 <. <2 <2<6 <23><21<. Bun,($ t $ #$'*&n&n@ p&$"$! *n, p(*"$ *n [MS\ !t&"?$# +n t $ t+p p&$"$.11. N+ 5un,($ '*- *)$ '+#$ t *n 12 p&$"$! + '*&( &n &t.
T $#$ &(( 5$ t$n !$t! + ,*t*. E*" !$t "+n!&!t! + * p+!&t&)$ &nt$@$# N +((+ $, 5- N p*&#! + nut $ nu'5$# + p&$"$! @+&n@ t+ $*" 8&p "+,$. F+# $ *'p($6 t $ &#!t (&n$ 5$(+ *! p&$"$! + '*&*n, : p&$"$! + '*&( +# <1 4 . F+# $*" !$t + ,*t*6 p#&nt t $ nu'5$# + ,& $#$nt t-p$! + 5un,($! DMS% t *t -+u *)$ &t (*5$(!. Y+u 'u!t n+t (&!t *n- 5un,($>t-p$! t *t *#$ 8$#+.
0ample .nput(L&n$ 1 26 6 <2 1<6 :6 <1 4L&n$ 2 6 6 <2 1<6 1:6 <2 2<6 26 <1 246 :6 <1 34
6 <1 4 6 6 <1 3 6 6 <22446 1 6 <2 3:
0ample :utput(Output 1 MSX1Output DX2 3X1 AX1 MSX1
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 407/499
Universidad Interamericana de Puerto RicoRecinto de Bayamón
CO-;2/2NCI"S 2 ;?O<?"-"CI@N9
;rincipiantes
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 408/499
.nterBay
-ay &,J 'KK=
BeginnersProgam &
CO0NTC5ARS
T &! p#+5($' #$ u&#$! -+u t+ p$# +#' !+'$ *n*(-!&! +n * &($ + t$ t. M+#$ !p$"& &"*((-6 &t #$ u&*t $*" (&n$ + t $ &($ *n, #$p+#t +n + '*n- upp$#>"*!$ ($tt$#!6 (+ $#>"*!$ ($tt$#!6 *n, n+n>($tt$"+nt*&n!.
T $ &nput &($ &(( "+nt*&n *t ($*!t +n$ (&n$ + t$ t6 5ut -+u ,+ n+t ?n+ + '*n- (&n$!. L&n$! '*- ($n@t 6 up t+ * '* &'u' + < " *#*"t$#!6 *n, t $#$ '*- 5$ 5(*n? (&n$!. N+t$ t *t t $ p#$)&+u! t + !t*t$&'p(- t *t * &($ '*- "+nt*&n 0u!t * !&n@($ 5(*n? (&n$.
Y+u# p#+@#*' 'u!t #$*, t $ (&n$! + t$ t &n t $ &nput &($ *n, 'u!t p#+,u"$ +n$ +utput (&n$ +# $*"&n t $ &($. E*" !u" (&n$ + +utput 'u!t *)$ t $ +((+ &n@ +#'
L&n$h "+nt*&n!h "*p&t*( ($tt$#!6h (+ $#>"*!$ ($tt$#!6 *n,h n+n>($tt$#!.
In &" t $ &#!t u$!t&+n '*#? h% #$p#$!$nt! t $ (&n$ nu'5$#6 t $ !$"+n, *n, t &#, u$!t&+n '*#?! #t $ nu'5$# + upp$#>"*!$ "*p&t*(% ($tt$#! *n, (+ $#>"*!$ !'*((% ($tt$#!6 #$!p$"t&)$(-6 *n, t $ &n'*#? #$p#$!$nt! t $ nu'5$# + n+n>($tt$# " *#*"t$#!. T $ $n,>+ >(&n$ " *#*"t$# &! &t!$( n+t "+unt
N+t$ "*#$ u((- t $ +#'*t + $*" +utput (&n$ It 'u!t 5$ * "+'p($t$ !$nt$n"$6 t$#'&n*t$, 5- * p$#&+,6nu'$#&"*( )*(u$ &! p#$"$,$, *n, +((+ $, 5- * !&n@($ !p*"$.
N+t$ &n t $ !*'p($ &nput ,*t* &($! &" +((+ t *t t $#$ *#$ n+ 5(*n? !p*"$! * t$# t $ (*!t )&!&5($ "$*" (&n$.
XXS*'p($ &nput ,*t* "+nt*&n$, &n COUNTCJARS1.DATXXT &! &! VERY GOOD TIME6 5$(&$)$ &t +#6 n+t t+ 5$ UITE CAREFUL.I -+u *#$ n+t6 $((6 t &n@! "*n @+ KRONGWW N+t +n(- t *t6 BUT6 &t &(( t*?$ -+u t&'$ t+ '*?$ t $' #&@ t W %XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX+utput +# &nput ,*t* #+' COUNTCJARS1.DATXL&n$ 1 "+nt*&n! 2 "*p&t*( ($tt$#!6 23 (+ $#>"*!$ ($tt$#!6 *n, 1 n+n>($tt$#!.L&n$ 2 "+nt*&n! : "*p&t*( ($tt$#!6 2 (+ $#>"*!$ ($tt$#!6 *n, 12 n+n>($tt$#!.L&n$ 3 "+nt*&n! < "*p&t*( ($tt$#!6 < (+ $#>"*!$ ($tt$#!6 *n, < n+n>($tt$#!.L&n$ 4 "+nt*&n! 4 "*p&t*( ($tt$#!6 42 (+ $#>"*!$ ($tt$#!6 *n, 23 n+n>($tt$#!.XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX,*t* "+nt*&n$, &n COUNTCJARS2.DATXXA*B5C"D,E$F G@J I&H0 ?L(M'NnO+Pp R#S!TtUuV)K ; Y- 81234 : <gWy ^x e %l> Xjcm Q \adfZh6.b ,+ SEEM 5$ ALL + t +!$ pun"tu*t&+n " *#*"t$#!.T $#$ +n"$ *! * '*n #+' P$#uK + ,#$*'t $ *! $*t&n@ &! ! +$WJ$ * +?$ &n t $ n&@ t
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 409/499
K&t * t$##&5($ #&@ tAn, +u@ t &t *! p$# $"t(- t#u$WW
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX+utput +# &nput ,*t* #+' COUNTCJARS2.DATL&n$ 1 "+nt*&n! 2: "*p&t*( ($tt$#!6 2: (+ $#>"*!$ ($tt$#!6 *n, 1< n+n>($tt$#!.L&n$ 2 "+nt*&n! "*p&t*( ($tt$#!6 32 (+ $#>"*!$ ($tt$#!6 *n, 41 n+n>($tt$#!.L&n$3 "+nt*&n! 2 "*p&t*( ($tt$#!6 22 (+ $#>"*!$ ($tt$#!6 *n, 1< n+n>($tt$#!.L&n$ 4 "+nt*&n! 1 "*p&t*( ($tt$#6 2: (+ $#>"*!$ ($tt$#!6 *n, n+n>($tt$#!.L&n$ "+nt*&n! 1 "*p&t*( ($tt$#6 1: (+ $#>"*!$ ($tt$#!6 *n, 4 n+n>($tt$#!.L&n$ : "+nt*&n! 1 "*p&t*( ($tt$#6 1 (+ $#>"*!$ ($tt$#!6 *n, 3 n+n>($tt$#!.L&n$ "+nt*&n! 1 "*p&t*( ($tt$#6 2 (+ $#>"*!$ ($tt$#!6 *n, n+n>($tt$#!.L&n$ "+nt*&n! < "*p&t*( ($tt$#6 < (+ $#>"*!$ ($tt$#6 *n, < n+n>($tt$#!.
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 410/499
.nterBay
-ay &,J 'KK=
BegginersProgram '
Decoding an Encoded Te9!file
T &! p#+5($' #$ u&#$! -+u t+ ,$"+,$ *n $n"+,$, &($ + t$ t *n, ,&!p(*- t $ #$!u(t &.$.6 t $ [p(*&n t$!"#$$n.
F&#!t6 +# !&'p(&"&t-6 -+u '*- *!!u'$ t *t t $ +n(- " *#*"t$#! &n *n- +#&@&n*( p(*&n t$ t &($ $#t $ 5(*n? !p*"$ " *#*"t$#6 *n, t $ $n,>+ >(&n$ " *#*"t$# *(!+ "*(($, t $ [n$ (&n$ " *#*"t$#\6 +# t $ " *#*"t$#\% &" &n,&"*t$! $#$ t $ (&n$ 5#$*?! *#$ (+"*t$,.
K$ ! *(( ,$!"#&5$ + *n- &nput &($ +# -+u# p#+@#*'6 &" 'u!t 5$ "*(($, TEST.DAT6 *! $n"+,$,. $ ! *(( ,$!"#&5$ + t $ +#&@&n*( p(*&n t$ t &($ *! t#*n! +#'$, &nt+ t $ $n"+,$, t$ t &($ t *t -+u# 'u!t n+ ,$"+,$.
F&#!t + *((6 t+ $n"+,$ * &($6 *(( " *#*"t$#! &n &t *#$ #$*, +n$ *t * t&'$. I t $ " *#*"t$# &! +n$ A6 B6 6 t $n &t &! $n"+,$, 5- #&t&n@ +ut t $ t + ,&@&t " *#*"t$#! @&)&n@ &t! nu'$#&"*( p+*(p *5$t <1 +# A6 <2 +# B6 2: +# %. I &t &! *n $n,>+ >(&n$ " *#*"t$# &t &! $n"+,$, *! 2 *n,!p*"$ &t &! $n"+,$, *! 2 .
A(!+6 *! t $!$ ,&@&t! *#$ #&tt$n +ut t+ t $ +utput &($6 *! !++n *! 4< ,&@&t! "+##$!p+n,&n@ t" *#*"t$#!% *)$ 5$$n #&tt$n +ut6 * n$ (&n$ + +utput &! !t*#t$,. T u! $)$#- (&n$ &n *n $n"+,$, u!u*((-% t $ (*!t "+nt*&n! $ *"t(- 4< ,&@&t " *#*"t$#!.
On"$ ,$"+,$,6 t $ p(*&n t$ t 'u!t 5$ ,&!p(*-$, +n t $ !"#$$n &t (&n$ 5#$*?! &n t $ p#+p$# p(*"$!6 *t $ !*'p($ +utput 5$(+ .
XX S*'p($ &nput ,*t* #+' DECODE1.DAT XX2<< < 1 2 < 1 2 2<< < 2 1 212<1:212<2 <:1 1 132 <1142 < 14<31 <4< <42 2<< 1 2<2<:< 12< 2 < 2<2 <31 142<<1< 141 2 1 < 22< 1 <1122 12< 14< 1 2 1 <:2 2<< 242<2 21 212 <3<1142 2<< < 14112 1 <:2 < <1<3<2 12< 14< 2 <11 2 <12 1 < 142<< 14<3< 2< 22< 142 2<< 1 21< < 2 < 2<2 < <11 2 14
1 2 1:2114<32<21<12<< 1 142 1 1 2 2 1 212 <3<1142 2<< < 14112 23< <12<< 22< 1 2< 121 < 2 2 1 212 12< 11< 2 2<< < 1 2 <1 2 2<< < 2 12<11 2<2 12< 14< 2
XX En, + &nput ,*t*bSt*#t + "+##$!p+n,&n@ +utput ,*t* XXTJIS IS TJE OUTPUT FROM AN ENCODED TEST FILE IT CONTAINS SEVERAL LINES OF TEYOU CAN TJIN OF EACJ LINE AS A SENTENCE EVEN TJOUGJ IT JAS NO PUNCTUATON OYOU CAN TJIN KJATEVER ELSE YOU LI E TJIS IS TJE LAST LINEXXXX En, + +utput ,*t* XXX
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 411/499
XXXX S*'p($ &nput ,*t* #+' DECODE2.DATXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX2 2 2 2 2 2<< < 1 < 2 2<231 2 12< 14< 12 <:1 12121 232 <12 <:< 1 1 2<2 <212<114112 12< 14< 2 2 2 2 2 <114<42 <11 < 2 <<1<3< 2 < 14<4< 142<< <42 <22 2 <:1 2112 1 1:<1<3< 1 2XXXX En, + &nput ,*t*bSt*#t + "+##$!p+n,&n@ +utput ,*t*XXXXXXXXXXXXXXXXXXXXXX
TJESE TKO LINES FOLLOK A FIRST BLAN LINE AND ARE EACJ INDENTED BY FOUR SPAXXXX En, + +utput ,*t* XXXX
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 412/499
.nterBay-ay &,J 'KK=
BeginnersProgram =
Hiru" De!ec!ion
K $n $ *'&n&n@ * &($6 * "$#t*&n )&#u! !"*nn$# (++?! +#6 *'+n@ +t $# t &n@!6 +""u##$n"$! +t $ &($. F+# $ *'p($6 t $ (&n$
*512^)&#u!23
*pp$*#&n@ &n !+'$ &($ +u(, 5$ '*#?$, *! !u!p$"t6 *! &t "+nt*&n! *n +""u##$n"$ + t $ !t#&n@ [+ $)$#6 t+ *(!+ (++? +# *t *#$ "*(($, [!"*tt$#$, +""u##$n"$!\ + t $ !t#&n@ [)&#u!\. F+# $ *'p($6
"+nt*&n! * [!"*tt$#$, +""u##$n"$\ + t $ !t#&n@ [)&#u!\6 &" &! &n,&"*t$, 5- t $ un,$#(&n$ " *#$)$n &n * [!"*tt$#$, +""u##$n"$\ + t $ +#, t $ +#,$# + t $ ($tt$#! #$'*&n! t $ !*'$ *! &n t $ "+##$"t(+#, [)&#u!\.
Y+u# t*!? &! t+ #&t$ * p#+@#*' t *t #$*,! $*" (&n$ &n * t$ t &($ "*(($, TEST.DAT6 *n, +utput! t+ $)$#- (&n$ + t$ t &" "+nt*&n! $&t $# * ,&#$"t +""u##$n"$ + t $ !t#&n@ [)&#u!\6 +# * [!"*tt$+ t $ !t#&n@ [)&#u!\6 *! ,$!"#&5$, *5+)$. T $ &#!t (&n$ + t $ &($ "+nt*&n! 0u!t t $ nu'5$# + (&+((+ . T $ (&n$! + t$ t &n t $ &($ #+' (&n$ 2 + t $ &($ +n *#, *)$ [(&n$ nu'5$#!\ !t*#t&n@ *t 1
XXXXS*'p($ &nput ,*t* #+' VIRUS1.DAT4,! ,)& , ,# ))))&#u!23$4y 1))& ,!"#32uu2!!xx@ !,
XXXXEn, + &nput ,*t*bSt*#t + "+##$!p+n,&n@ +utput ,*t*XXXX'=XXXXEn, + +utput ,*t*XXXX
XXXXS*'p($ &nput ,*t* #+' VIRUS2.DATXXXX:&t&!)$#-&n)&@+#*t&n@t+#un*#+un,t $!?-!"#*p$#.T &! (&n$ ,+$! n+t "+nt*&n t $ )e&e#eue! !t#&n@. O# ,+$! &th% ex V y^yze%e% R < ue%e%eS N+ &!t $t&'$ +#*(( *"?$#!*n,))))&&&###uuu!!! #&t$#!t+"$*!$*n,,$!&!TWF*0(")0&+#- $+p# *)?* -&$!,0)+$ 5@P&#+ut#@5! +@u+ @n?tn n!? ? ? ? ? 5 !???( $&?5'*, @&-$ tXXXXEn, + &nput ,*t*bSt*#t + "+##$!p+n,&n@ +utput ,*t*XXXX&'+XXXXEn, + +utput ,*t*XXXX
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 413/499
.nterBay
-ay &,J 'KK=
BeginnersProgram +
Number Proper!ie"
A p+!&t&)$ &nt$@$# &! "+n!&,$#$, p#&'$ & &t &! $)$n(- ,&)&!&5($ +n(- 5- &t!$( *n, 1. A(!+6&t!$( * p#&'$. T u!6 t $ !$ u$n"$ + p#&'$! 5$@&n 26 36 6 61161361 6
A p+!&t&)$ &nt$@$# &! "*(($, p$# $"t & &t &! t $ !u' + &t! p#+p$# ,&)&!+#. F+# $ *'p($6 2 &! 5$"*u!$ 2 X 1 2 4 14.
Y+u# *!!&@n'$nt &! t+ #&t$ * p#+@#*' t *t &(( &nput * !$ u$n"$ + &nt$@$#!6 +n$ p$# (&n$6 * p#+p$#t&$! + $*" &nt$@$# &n t $ +((+ &n@ +#'*t
I t $ nu'5$# &! n$&t $# p#&'$ n+# p$# $"t6 +utput [Du((\.I t $ nu'5$# &! p#&'$ 5ut n+t p$# $"t6 +utput [P#&'$\.I t $ nu'5$# &! p$# $"t 5ut n+t p#&'$6 +utput [P$# $"t\.I t $ nu'5$# &! 5+t p#&'$ *n, p$# $"t6 +utput [T &! p#+@#*' ,+$!ndt +#?\.A(( &nput &(( 5$ p+!&t&)$ &nt$@$#!. T $ $n, + &nput &(( 5$ '*#?$, 5- t $ nu'5$# < n+ +utput !@$n$#*t$, +# <%.
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXE *'p($XXXX.nputXXXX2
14<1
<XXXX:utput XXXX
Per*e+t Prime ,ull ,ull Prime
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 414/499
.nterBay
-ay &,J 'KK=
BeginnersProgram
Time Card
H$nn- 0u!t !t*#t$, +#? *! * p#+@#*''$# +# Hu!t&n$d! H*)* K+#?! +p. S $ &! p*&, ^1< *n +u#6 $ "$pt&+n!. S $ $*#n! *n $ t#* ^1. < *n +u# +# *n- p*#t + * ,*- $#$ ! $ +#?! '+#$ t *t +u#6 *n, $ t#* ^2. < *n +u# +# +u# 5$-+n, 4< &n *n- +n$ $$?. A(!+6 ! $ $*#n! * 2 x 5+nu! +# +#?&n@ +*n, * <x 5+nu! +# +#?&n@ +n Sun,*-. T $ 5+nu!$! +# S*tu#,*- *n, Sun,*- *#$ "+'put$, 5*!$, +n t+u#! +#?$, t +!$ ,*-!a t $- *#$ n+t u!$, t+ "*("u(*t$ *n- 5+nu! +# +#?&n@ '+#$ t *n 4< +u#! &n *
Y+ud(( 5$ @&)$n t $ nu'5$# + +u#! H$nn- +#?$, $*" ,*- &n * $$? Sun,*-6 M+n,*-6 6 S*tu#,*-%-+u n$$, t+ "+'put$ $# !*(*#- +# t $ $$?. T $ &nput &(( 5$ p+!&t&)$ &nt$@$#!6 ($!! t *n +# $ u*+utput 'u!t 5$ +#'*tt$, &t * ,+((*# !&@n *n, #+un,$, t t $ n$*#$!t p$nn-. F+# $ *'p($6 [^2\ *n,[^2.13::::\ *#$ #+n@ *n! $#!a t $ "+##$"t )$#!&+n! *#$ [2.<<\ *n, [^2.14\6 #$!p$"t&)$(-. T $#$ '*- *n- $'5$,,$, !p*"$! &n -+u# *n! $#!. T $#$ &(( 5$ !$t! + ,*t*.
XXXX0ample .nput(XXXX
L&n$ 1 <6 6 6 6 1<6 :6 <L&n$ 2 46 <6 <6 <6 <6 :6 <XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
0ample :utput(
:utput &( f+K=4KK:utput '( f&'K4KK
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 415/499
Universidad Interamericana de Puerto RicoRecinto de Bayamón
CO-;2/2NCI"S 2 ;?O<?"-"CI@N
23pertos
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 416/499
Un&)$#!&,*, Int$#*'$#&"*n* ,$ Pu$#t+ R&"+R$"&nt+ ,$ B*-*'7n
T$#"$#*! O(&'p&*,*! ,$ P#+@#*'*"&7n !N" R $% &''&
CATEGORrA DE E;PERTO
In!t#u""&+n$! @$n$#*($!
T+,+! (+! p#+5($'*! ,$ $!t* "*t$@+#`* !$#_n &nt$#*"t&)+!. NO ($$n ,*t+! ,$!,$ *#" &)+! $ t$#n+!%ut&(&8*# p*#* #$!+()$#(+! (+! !&@u&$nt$! ($n@u*0$! V&!u*( B*!&" + C . D$5$n $nt#$@*#!$"+'+ (+ *-*! t$#'&n*,+.
PROBLEMA 1
Mul!iplicación Ru"a
En $( !&@(+ p*!*,+ $n Ru!&*6 (+! "*'p$!&n+! !$ !$#)`*n ,$ un &n@$n&+!+ ' t+,+ ,$ 'u(t&p(&"*"&!7(+ n$"$!&t*5*n !*5$# $n"+nt#*# $( ,+5($ - (* '&t*, ,$ un n/'$#+6 *!` "+'+ (* $($'$nt*( +p$#*"&7n C+n $!t$ !&!t$'* *5`* u$ +#'*# ,+! "+(u'n*! $n"*5$8*,*! p+# (*! "& #*! u$ !$ &5*n * 'u(t&p(&"*#
E( ' t+,+ +p$#* $n (* !&@u&$nt$ +#'*
E0$'p(+ Mu(t&p(` u$!$ p+# 3
*% S$ !*"* !u"$!&)*'$nt$ (* '&t*, * (+! n/'$#+! !&tu*,+! $n (* "+(u'n* ,$ (* &8 u&$#,* !&n t+"u$nt* (+! #$!&,u+!%6 - $( ,+5($ * (+! ,$ (* "+(u'n* ,$#$" *. S$ "+nt&n/* $!t* +p$#*"&7n *"+(u'n* &8 u&$#,* !$ #$,u8"* * (* un&,*,.
3424 1 :12 312: :243 1241 24 :
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 417/499
5% S$ t*" *n t+,*! (*! "& #*! p*#$! u$ &@u#$n $n (* "+(u'n* &8 u&$#,* - p+# "+n!&@u&$n"+##$!p+n,&$nt$! $n (* "+(u'n* ,$#$" *.
; 3
4 ;2
4; 1
:1
2; 3
12: ; :
243 ; 1
24
1 ; 24 :
"% F&n*('$nt$ !$ !u'*n (*! "& #*! u$ u$,*n $n (* "+(u'n* ,$#$" *. E( t+t*( ,$ (* !u'* $! $( #$!u
3 124 24 : X 3 3
Problema(
D$!*##+(($ un p#+@#*'* u$ !+(&"&t$ *( u!u*#&+ - 'u(t&p(& u$ ,+! "& #*! n+ '$n+#$! ,$ 2 ,`@&t+. E( p#+@#*'* t&$n$ u$ $ $"tu*# (+! '&!'+! p*!+! '$n"&+n*,+! *nt$#&+#'$nt$ p*#* p+,$# (($@*#
$%emplo de .nput(
In,& u$ $( p#&'$# ,`@&t+VIn,& u$ $( !$@un,+ ,`@&t+=V
$%emplo de :utput(
34 f>S$ $(&'&n*24 1 : f>S$ $(&'&n*12 312 f>S$ $(&'&n*: :24 f> S$ $(&'&n*3 1241 24 :
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 418/499
3 124 24 :
RESULTADOX 3 3
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 419/499
PROBLEMA 2
Her!ical 5i"!ogram
E!"#&5$ un p#+@#*'* u$ *"$pt$ ,`@&t+! <> % "+'+ Input. D$ "+'+ #$!u(t*,+ $( &)$#t&"*( #$p#$!$nt*t&)+ ,$ "*,* ,`@&t+. C*("u(* t*'5& n (* !u'* ,$ t+,+! (+! ,`@&t+!6 $( p
,* "+'+ #$!u(t*,+ (* (&!t* ,$ (+! n/'$#+! p+# ,$5*0+ ,$( p#+'$,&+ !&n #$p$t&# - (* (&!t* ,$ ( p+# ,$5*0+ ,$( p#+'$,&+ !&n #$p$t&# - (* (&!t* ,$ (+! n/'$#+! p+# $n"&'* ,$( p#+'$,&+ !&n
V$#& &"* tu p#+@#*'* "+n $!t$ !$t ,$ 13 ,`@&t+!.16 626 6:6 61636 6 6 6 6<
E0$'p(+ ,$ Input
Ent$# * Nu'5$# 12Ent$# 12 ,&@&t!16 626 6:6 61636 6 6 6
E0$'p(+ ,$ Output
ee
e e eeee eee e<1234 :
L* !u'* $! :4 E( p#+'$,&+ $! .3L+! n/'$#+! p+# ,$5*0+ !+n 16263L+! n/'$#+! p+# $n"&'* :6 6
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 420/499
PROBLEMA 3
K#&t$ * p#+@#*' t+ #$*, &n t + 2>,&'$n!&+n*( *##*-!6 *n, t $n 'u(t&p(- +n$ 5- t $ +T &! "*(($, '*t#& 'u(t&p(&"*t&+n. F+# $ *'p($6 & &#!t A##*- 2>#+ 5- 2>"+(u'n *##*-%
3
*n, !$"+n,A##*- 2>#+ 5- 1>"+(u'n *##*-% *pp$*#! *!
:
t $n t $ p#+,u"t '*t#& &!
p#+,u"tM*t#& Q< Q< X 2 e e : p#+,u"tM*t#& Q1 Q< X e 3 e :
M*t#& 'u(t&p(&"*t&+n "*n 5$ ,+n$ +n(- & t $ nu'5$# + "+(u'n! &n t $ 'u(t&p(&"*n, t $ &#!t *##*nu'5$# + #+ ! &n t $ 'u(t&p(&$# t $ !$"+n, *##*-%.
T $ p#+@#*' ! +u(, #$*, &n t $ t + *##*-!6 t$!t t+ !$$ + 'u(t&p(&"*t&+n &! p+!!&5($6 *n, t $n 'u(t&&!. T $ +utput &(( 5$ * p#&nt+ut + t $ t + *##*-! *n, &(( $&t $# +utput t $ p#+,u"t *##*- +# p#&n!*-&n@ t *t 'u(t&p(&"*t&+n &n n+ p+!!&5($.
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 421/499
PROBLEMA 4
K#&t$ *n &nt$#*"t&)$ p#+@#*' t *t p(*-! t&">t*">t+$. R$p#$!$nt t $ 5+*#, *! * t #$$>5->t #$$ " *In&t&*(&8$ t $ *##*- t+ 5(*n?! *n, $*" p(*-$# &n tu#n t+ &nput * p+!&t&+n. T $ &#!t p(*-$#d! p'*#?$t +n t $ 5+*#, &t * <6 *n, t $ !$"+n, p(*-$#d! p+!&t&+n &(( 5$ '*#?$t &t *n ;. C+nt&nu$ t $unt&( * p(*-$# &n! +# t $ @*'$ &! * ,#* . T+ &n6 * p(*-$# 'u!t *)$ t #$$ '*#?! &n * #+ 6 &n * "+(* ,&*@+n*(. A ,#* +""u#! $n t $ 5+*#, &! u(( *n, n+ +n$ *! +n.
E*" p(*-$#d! p+!&t&+n ! +u(, 5$ &nput *! &n,&"$! &nt+ t $ t&">t*">t+$ 5+*#, t *t &!6 * #+ nu'5$* "+(u'n nu'5$#. M*?$ t $ p#+@#*' u!$#> #&$n,(-.
A t$# $*" @*'$6 p#&nt +ut * ,&*@#*' + t $ 5+*#, ! + &n@ t $ $n,&n@ p+!&t&+n. $$p * "+unt +@*'$! $*" p(*-$# *! +n *n, t $ nu'5$# + ,#* !. B$ +#$ t $ 5$@&nn&n@ + $*" @*'$6 *!? $*" p(*$ +# ! $ &! $! t+ "+nt&nu$. I $&t $# p(*-$# &! $! t+ u&t6 p#&nt +ut t $ !t*t&!t&" *n, !t+p.
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 422/499
Universidad Interamericana de Puerto RicoRecinto de Bayamón
CO-;2/2NCI"S 2 ;?O<?"-"CI@N
Intermedios
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 423/499
Un&)$#!&,*, Int$#*'$#&"*n* ,$ Pu$#t+ R&"+R$"&nt+ B*-*'7n
P#&'$#*! O(&'p&*,*! ,$ P#+@#*'*"&7n !N" R $% &''&
CAT$9:R A0 #$ .NT$R-$#.:0
In!t#u""&+n$! @$n$#*($!
T+,+! (+! p#+5($'*! ,$ $!t* "*t$@+#`* !$#_n &nt$#*"t&)+!. NO ($$n ,*t+! ,$!,$ *#" &)+! $ t$#n+!%ut&(&8*# p*#* #$!+()$# (+! !&@u&$nt$! ($n@u*0$! V&!u*( B*!&" + C . D$5$n $nt#$@*#!$ $*-*! t$#'&n*,+.
PROBLEMA 1
T e In be!Keen Sum
Problema(
Y+u *#$ @&)$n t + nu'5$#!6 A *n, B6 *n, -+u *)$ t+ &n, t $ t+t*( + *(( t $ nu'5$#! 5$t $$n t $!$ t +nu'5$#!. F+# $ *'p($ & -+u *#$ @&)$n t $ nu'5$#! 6 *n, 1 6 -+u 1 6 -+u 'u!t &n, t $ !u'1< 11 12 13 14 &" &! :<.
$%emplo de .nput(
T $ &nput &! t $ p*&# + &nt$#@$#!6 A *n, $ 1 fXA fXB fX 3<<<<%.
$%emplo de :utput(
T $ +utput &(( 5$ t $ !u' + *(( t $ nu'5$#! 5$t $$n A *n, B.
$5ample &
.nput 1:utput:<
$5ample '
.nput1< 2<:utput13
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 424/499
PROBLEMA 2
U!*n,+ un* t*5(* !$n"&((* un *##$@(+ ,$ +#,$n 1% #$!u$()* $( !&@u&$nt$ p#+5($'*. Un* "+'p*9)$n,$,+#$! #$"&5$n ^2<< !$'*n*('$nt$ '_! $( x ,$ (*! )$nt*! ,$ $!* !$'*n*. P+# $0$'p(+6 un )$n,$,+#u$ )$n,* ^ <<<6 #$"&5$ ^2<< '_! $( x ,$ ^ 6<<<6 7 ^: <.
U!*n,+ un *##$@(+ ,$ "+nt*,+#$!6 ,$t$#'&n$ "u_nt+! )$n,$,+#$! #$"&5&$#+n un !*(*#&+ $n "*,* !&@u&$nt$! $!"*(*!
*. ^2<<>2 >2 . ̂ <<> >4 5. ^3<<>3 >4 @.^ <<> >3". ^4<<>4 >4 .^ <<> >4,. ^ <<> >3 &. ̂ 16<<< >$. ^:<<>: >4
U!* (+! !&@u&$nt$! ,*t+! ,$ )$nt*!
1<<< 11<< 14<< 1 << 1 << 21<<24<<2 << 3<<< 33<< 3:<< 3 << 42<<4 <<4 << <<< 3<< :<< << :2<<: <<<<< 2<< << << 1<< 3<<<<<<< 2<< << 1<2<< 1<3<< 11<<< 13<<<
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 425/499
PROBLEMA 3
E!"#&5* un p#+@#*'* u$ ($* un "*#_"t$# ,$ [A\ * (* [ \ - p#+,u8"* un* !*(&,* "+n +#'* ,$ p&#_'&"+n!&!t$ ,$ (+! "*#*"t$#$! $nt#*,+!. E( "*#_"t$# !up$#&+# ,$5$ !$# (* ($t#* [A\ - $n "*,* n&)$( !u($t#* $nt#*,* ,$5$ "*$# $n $( '$,&+ ,$ (+! "*#*"t$#$! $nt#*,+! *nt$#&#'$nt$.
AABAABCBA
ABC#CBAABC#$#CB
PROBLEMA 4
&Prin! a S!ring #ackKard'E!"#&5* un* un"&7n #$"u#!&)* u$ #$"&5* un *##$@(+ u$ "+nt&$n$ un [!t#&n@\ "+'+ *#@u'$n[!t#&n@\ - ,$)u$()$ n*,*. E( p#+@#*'* t$#'&n* !u $0$"u"&7n "u*n,+ $n"u$nt#* un [nu(( "*#_"t$#\
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 426/499
Universidad Interamericana de Puerto RicoRecinto de Bayamón
CO-;2/2NCI"S 2 ;?O<?"-"CI@N
;rincipiantes
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 427/499
Un&)$#!&,*, Int$#*'$#&"*n* ,$ Pu$#t+ R&"+R$"&nt+ ,$ B*-*'7n
P#&'$#*! O(&'p&*,*! ,$ P#+@#*'*"&7n !N" R $% &''&
CAT$9:R A0 #$ PR.NC.P.ANT$0
Int#u""&+n$! @$n$#*($!
T+,+! (+! p#+5($'*! ,$ $!t* "*t$@+#`* !$#_n &nt$#*"t&)+!. NO ($$n ,*t+! ,$!,$ *#" &)+! $ t$#n+!%ut&(&8*# p*#* #$!+()$#(+! (+! !&@u&$nt$! ($n@u*0$! V&!u*( B*!&" + C . D$5$n $nt#$@*#!$"+'+ (+ *-*! t$#'&n*,+.
PR:B!$-A &
P#$p*#* un p#+@#*'* u$ "u$nt* $( n/'$#+ ,$ ($t#*!6 punt+! - (+! !&@n+! ,$ $ "(*'*"&7n $n (+! p#&"*#*"t$#$! ,$ un [!t#&n@\. I'p#&'$ $( [!t#&n@\ - $( t+t*( ,$ ($t#*!6 punt+!6 - !&@n+! ,$ $ "(*'*"&
Input zJOLAW. Fu$ un p(*"$# "+n+"$#t$. z u$ t$ )*((* 5&$nWOutput zJ+(*W. Fu$ un p(*"$# "+n+"$#t$. z u$ )*((*! 5&$nW
L$t#*!X 3 E "(*'*"&7n X4 Punt+!X2
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 428/499
PROBLEMA 2
Ro!a!ing 6ord"
Y+u *#$ #$ u&#$, t+ #+t*t$ * +#, * "$#t*&n *'+unt. F+# $ *'p($6 t+ #+t*t$ t $ +#, [C+'put$#\ 5- 1&n [#C+'put$\. R+t*t&n@ &t t + '+#$ t&'$! @&)$! -+u [t$#C+'pu\.
$%emplo de .nput(
T $ &#!t (&n$ "+nt*&n! t $ +#, &" &(( n+t *)$ '+#$ t *n 1 ($tt$#!%. T $ !$"+n, (&n$ "+nt*&n!&nt$@$# n6 &" &(( 5$ ($!! t *n t $ ($n@t + t $ +#,. Y+u 'u!t #+t*t$ t $ +#, n t&'$!.
$%emplo de :utput(
T $ +utput &(( 5$ t $ #+t*t$, +#,.
$5ample &
InputEnt#$ (* p*(*5#*ComputerEnt#$ (* "*nt&,*,=Outputt$#C+'pu
$5ample '
InputEnt#$ (* p*(*5#*ProgramEnt#$ (* "*nt&,*,&Output'P#+@#*
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 429/499
PR:B!$-A
A p*#?&n@ @*#*@$ " *n@$! * ^:.<< '&n&'un $$ t+ p*#? +# up t+ t #$$ +u#!. T $ @*#*@$ " *#^1. < p$# +u# +# $*" +u# +# p*#t t $#$ + &n $ "$!! + t#$$ +u#!. T $ '* &'u' " *#@$ +# *n- @&+u#! *t * t&'$. K#&t$ * p#+@#*' t *t &(( "*("u(*t$ *n, p#&nt t $ p*#?&n@ " *#@$! +# $*" "u!t+
p*#?$, &! +# $# "*# &n t &! @*#*@$ -$!t$#,*-. Y+u ! +u(, $nt$# t $ +u#! p*#?$, +# $*" "u!t+'$ p#+@#*' ! +u(, p#&nt t $ #$!u(t! &n * n$*t t*5u(*# *n, ! +u(, "*("u(*t$ *n, p#&nt t $ t+t*( + -$!t$#,#$"$&pt!. T $ p#+@#*' ! +u(, u!$ t $ p#+"$,u#$CalculateChargest+ ,$t$#'&n$ t $ " *#@$ +# $*""u!t+'$#.
PR:B!$-A +
K#&t$ * p#+@#*' t *t "+n)$#t! ($tt$#! + t $ *(p *5$t &nt+ t $&# "+##$!p+n,&n@ ,&@&t! +n t $ t$ p#+@#*' ! +u(, ($t t $ u!$# $nt$# ($tt$#! #$p$*t$,(- unt&( * +# * &! $nt$#$,. *n, *#$ t $ t + ($t*#$ n+t +n t $ t$($p +n$%. An $##+# '$!!*@$ ! +u(, 5$ p#&nt$, +# *n- n+n*(p *5$t&" " *#*"t$# t
T $ ($tt$#! *n, ,&@&t! +n t $ t$($p +n$ *)$ t $ +((+ &n@ "+##$!p+n,$n"$.
ABCX2 H LX TUVX DEFX3MNOX: K;YX GJIX4 PRSX
J$#$ * ($tt$# PT $ ($tt$# P "+##$!p+n,! t+ +n t $ t$($p +n$Ent$# * ($tt$# A
T $ L$tt$# A "+##$!p+n,! t+ 2 +n t $ t$($p +n$Ent$# * ($tt$# DT $ ($tt$# D "+##$!p+n,! t+ 3 +n t $ t$($p +n$Ent$# * ($tt$# 2In)*(&, ($tt$#. Ent$# +# t+ u&tEnt$# * ($tt$# u&t
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 430/499
Universidad Interamericana de Puerto RicoRecinto de Bayamón
CO-;2/2NCI"S 2 ;?O<?"-"CI@N'
23pertos
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 431/499
Un&)$#!&,*, Int$#*'$#&"*n* ,$ Pu$#t+ R&"+P#&'$#*! O(&'p&*,*! ,$ P#+@#*'*"&7n
.nterBay 'KK&
CAT$9:R A $OP$RT:0
In!t#u""&+n$! @$n$#*($!
T+,+! (+! p#+5($'*! ,$ $!t* "*t$@+#`* !$#_n &nt$#*"t&)+! - "+n *#" &)+! $ t$#n+!. Pu$,$! ut&(&8#$!+()$#(+! (+! !&@u&$nt$! ($n@u*0$! V&!u*( B*!&" + C . D$5$n $nt#$@*#!$ $n ,&!"+ t*n pt$#'&n*,+.
PRO#$EMA B
Un BpalindromeB $! un* p*(*5#* u$ !$ ,$($t#$* ,$ &@u*( '*n$#* *( ,$#$" + + *( #$) !6 t*( "+'+ \#*,*E!"#&5$ un p#+@#*'* u$ *"$pt* un* !$#&$ ,$ "*#*"t$#$! [!t#&n@\% "+n un punt+ *( &n*( - ,$t$ p*(*5#* !&n &n"(u&# $( punt+% $! un [ palindromeB . Tu pu$,$! *!u'&# u$ (* $nt#*,* ,$ (* p*(*5#* !$#_ $n'&n/!"u(* - u$ t&$n$ un (*#@+ '_ &'+ ,$ 2< "*#*"t$#$!. E( p#+@#*'* n+ t&$n$ u$ "+t$0*# !& (* #$*('$nt$ $( $!p*9+( + &n@( !. P+# $0$'p(+6 (* p*(*5#* [**55"55**\ !$ "+n!&,$#*#_ un [ palindromeB p+# tu p#+@#*'*.
P$#'&t$ (* &t$#*"&7n ,$( p#+@#*'* ,$ '*n$#* u$ ($ p$#'&t* *( u!u*#&+ "+t$0*# p*(*5#*! *,&"&+,$"&,* t$#'&n*#.
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 432/499
PR:B!$-A '
E!"#&5$ un p#+@#*'* u$ ($ *!&@n$ *!&$nt+! * (+! p*!*0$#+!. A!u'$ u$ (+! *!&$nt+! ,$( p$ u$9*!&@n*n !&@u&$n,+ $( p*t#7n * "+nt&nu*"&7n.
& A B C D' A B C D= A B C D
+ A B C DA B C D, A B C D
A B C D
E( p#+@#*'* ,$5$ ,$!p($@*# (+! *!&$nt+! ,$( *)&7n6 '*#"*n,+ "+n un*\O\6 * u$((+! *!&$nt+! +"up*,+!. P+#$0$'p(+ ,$!pu ! u$ (+! *!&$nt+!&AJ 'B y +C !$ +"up*n6 !$ ,$5$ ,$!p($@*# (+ !&@u&$nt$
D$!pu ! ,$ ,$!p($@*# (+! *!&$nt+! ,&!p+n&5($!6 $( p#+@#*'* ,$5$ p$,&# *( *!&$nt+ ,$!$*,+. E( un/'$#+ ,$( *!&$nt+ - !$ ,$!p(&$@* (+! ,*t+! *"tu*(&8*,+!. E!t+ "+nt&nu* *!t* u$ t+,+! (+! *!&$nt+"up*,+! + *!t* u$ $( u!u*#&+ &n,& u$ u$ ,$!$* t$#'&n*#. S& $( u!u*#&+ p&,$ un *!&$nt+ +"u p#+@#*'* ,$5$ *!` &n,&"*#(+ - p$,&# u$ !$ $nt#$ +t#+ *!&$nt+.
PRO#$EMA 2
E!"#&5$ un* un"&7n u$ ((*'*#$'+!merge-lists u$ *"$pt* ,+! *#@u'$nt+! ["*((>5->#$ $#$n"$[ u$ !+n)*#&*5($! u$ *punt*n *( p#&n"&p&+ ,$ ,+! (&!t*! $n"*,$n*,*! [(&n?$, (&!t!\% ,$ t&p+int A!u'$ u$ (*! ,+!(&!t*! $n"*,$n*,*! $!t_n +#,$n*,*! ,$ '*n$#* u$ $( )*(+# *( p#&n"&p&+ ,$ (* (&!t* $! $( )*(+# '_! p*punt* *( n/'$#+ u$ ($ !&@u$ $n t*'*9+ - *!` !u"$!&)*'$nt$. L* un"&7n ,$)u$()$ $( )*(+# ,$( *puntun* (&!t* $n"*,$n*,* u$ "+n!&!t$ ,$ (*! ,+! (&!t*! *nt$#&+#$!. L+! )*(+#$! ,$ $!t* (&!t* t*'5& n $+#,$n*,+!. E!t* un"&7n n+ "#$*#* n& ,$!t#u&#_ (+! n+,+! ,$ (* (&!t*. A( t$#'&n*# (* un"&7n6 (,$5$n t$n$# "+'+ "+nt$n&,+ $( )*(+# ,$ NULL.
& ; B C D' A ; C D= A B C D
+ A B ; DA B C D
, A B C DA B C D
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 433/499
Universidad Interamericana de Puerto RicoRecinto de Bayamón
CO-;2/2NCI"S 2 ;?O<?"-"CI@N'
Intermedios
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 434/499
Un&)$#!&,*, Int$#*'$#&"*n* ,$ Pu$#t+ R&"+P#&'$#*! O(&'p&*,*! ,$ P#+@#*'*"&7n
.nterBay 'KK&
CAT$9:R A #$ .NT$R-$#.:0
In!t#u""&+n$! @$n$#*($!
T+,+! (+! p#+5($'*! ,$ $!t* "*t$@+#`* !$#_n &nt$#*"t&)+! - "+n *#" &)+! $ t$#n+!. Pu$,$! ut&(&8#$!+()$#(+! (+! !&@u&$nt$! ($n@u*0$!. V&!u*( B*!&" + C . D$5$n $nt#$@*#!$ $n ,&!"+ t*n p*-*! t$#'&n*,+.
PR:B!$-A &
Programa Planilla forma cor!a,E!t$ p#+@#*'* "*("u(*#_ (* "+nt#&5u"&7n * p*@*#6 + !& $!t_ $ $nt+ ,$ p*@*# + !& ($ t&$n$n u"*nt&,*, #$t$n&,*. E( p#+@#*'* p$,&#_ (+! !&@u&$nt$! )*(+#$!
*% N+'5#$ ,$( "+nt#&5u-$nt$ 5% C*nt&,*, @*n*,* $n $( *9+"% C*nt&,*, #$t$n&,* ,u#*nt$ $( *9+,% D$,u""&+n$!
1% C*nt&,*, ,$ ,$p$n,&$nt$! !$ 'u(t&p(&"* p+# 162<<%2% Int$#$!$! ,$ *ut+ '_ &'+ ,$ 12<<6 )$#& &"*# ,&" * "*nt&,*,%3% E!t*tu!. S+(t$#+ + C*!*,+ ,$,u""&7n &0* S+(t$#+ X363<<. C*!*,+ X:6<<<%4% G*!t+! +#,&n*#&+! n$"$!*#&+! '_ &'+ ,$ 3x ,$ (* "*nt&,*, @*n*,*6 )$#& &"*# "*n% C*nt&,*, &n)$#t&,* $n IRA !& $! !+(t$#+ '_ &'+ ,$ 36<<< - C*!*,+ :6<<<%
$% C_("u(+!1% C*("u(*# $n un* un"&7n (* "*nt&,*, t+t*( ,$ ,$,u""&+n$! !u'*# (*! ,$,u""&+n$! *p(&2% C*("u(*# $n un* un"&7n (* "+nt#&5u"&7n * p*@*# ut&(&8*n,+ (* t*5(* ,$ "+nt#&$ $nt+ !& (* "*nt&,*, @*n*,* ,$!pu ! ,$ (*! ,$,u""&+n$! $! '$n+# + &@u*( * "$#+% +
#$!+()$# ,$ (* "*nt&,*, #$t$n&,* - "u_nt+.3% E( p#+@#*'* ,$5$# ,*# (+! #$!u(t*,+! "+##$!p+n,&$nt$! - un '$n!*0$ p*#* )+()$# *( M
"+'$n8*# "+n un nu$)+ "+nt#&5u-$nt$.
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 435/499
"abla .ontributivaNo mayor de f'JKKK 4$n e5ceso de f'JKKK
pero no en e5ceso def& JKKK
f& K m*s el &&del e5ceso de f'JKKK
$n e5ceso def& JKKK pero no en e5cesode f=KJKKK
f&JLKK m*s el&,4 del e5ceso def& JKKK
$n e5ceso def=KJKKK pero no en e5cesode f KJKKK
f=JV+ m*s el'V4 del e5ceso def=KJKKK
$n e5ceso def KJKKK
fVJL+ m*s el ==del e5ceso de f KJKKK
PRO#$EMA 4
En un *#" &)+ $ t$#n+ ,$ t&p+ TE;T $ &!t$ un* (&!t* ,$ n/'$#+! ,$ t$( +n+!. !t+! "+nt&$n$n n/'$($t#*! $0$ *(>2 4 7 4>E *'. J*"$# un* (&!t* ,$ (+! n/'$#+! ,$ t$( +n+! +#&@&n*($! - *( (*,+
$ u&)*($nt$ $n +#'*t+ ,$ !7(+ n/'$#+ + !$* #$'p(*8*# (*! ($t#*! p+# n/'$#+! !$@/n $( "7,&@+ ,$( tD$5$ "+nt$n$# p+# (+ '$n+! 1 #$"+#,.
./0igo
' A>B>C = #>$>F + 9>;>. >8>D>! , ->N>:P>E>R>0 L T>U>/ V @>O> >"
PRO#$EMA 2
2. J*"$# un p#+@#*'* u$ p&,* $!"#&5&# un p_##* + - (u$@+ ,$! ENTER p*#* t$#'&n*#. D* "+'"*nt&,*, ,$ "*#*"t$#$! u!*,+! !&n "+nt*# (+! $!p*"&+! - (* "*nt&,*, ,$ p*(*5#*! u$ "+nt&$n$.
PR:B!$-A +
Programa Promedio",L$$# un* (&!t* ,$ 1 n+t*! ,$ $ _'$n$! ,$ un '_ &'+ ,$ 1<< u$ $!t_ $n un *#" &)+ $ t$#n+ ((*'*,+notas4dat - @u_#,*(+! $n un A##*-. En un* un"&7n !$ "*("u(*#_ $( p#+'$,&+ ,$ ,&" * (&!t*. D*# "#$!u(t*,+
*% L* (&!t* ,$ (+! n/'$#+! 5% E( p#+'$,&+ ,$ ,&" * (&!t*"% Un* (&!t* ,$ (*! n+t*! p+# ,$5*0+ ,$( p#+'$,&+,% E( p#+'$,&+ ,$ (* (&!t* ,$ n+t*! p+# ,$5*0+$% Un* (&!t* ,$ (*! n+t*! p+# $n"&'* ,$( p#+'$,&+% E( p#+'$,&+ ,$ (* (&!t* p+# $n"&'* ,$( p#+'$,&+L* un"&7n u$ "*("u(* $( p#+'$,&+ !$ ((*'*#_ 3 )$"$!.
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 436/499
Universidad Interamericana de Puerto RicoRecinto de Bayamón
CO-;2/2NCI"S 2 ;?O<?"-"CI@N'
;rincipiantes
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 437/499
Un&)$#!&,*, Int$#*'$#&"*n* ,$ Pu$#t+ R&"+P#&'$#*! O(&'p&*,*! ,$ P#+@#*'*"&7n
.nterBay 'KK&
CAT$9:R A #$ PR.NC.P.ANT$0
In!t#u""&+n$! @$n$#*($!
T+,+! (+! p#+5($'*! ,$ $!t* "*t$@+#`* !$#_n &nt$#*"t&)+! + ,$ *#" &)+! $ t$#n+!. Pu$,$! ut&(&8*#$!+()$#(+! (+! !&@u&$nt$! ($n@u*0$! V&!u*( B*!&" + C . D$5$n $nt#$@*#!$ $n ,&!"+ t*n p#t$#'&n*,+.
PROBLEMA 1
Programa de nWmero"
J*"$# un p#+@#*'* u$ p&,* un* "*nt&,*, ,$ n/'$#+! &n,$t$#'&n*,+! - un !$nt&n$( p*#* t$#'&n*#. #$!u(t*,+ (+ !&@u&$nt$
*% Cu_nt+! u$#+n p+!&t&)+! 5% Cu*nt+! u$#+n n$@*t&)+!"% Cu*nt+! u$#+n "$#+!,% P#+'$,&+ ,$ (+! p+!&t&)+!$% L&!t* ,$ (+! p+!&t&)+!% L&!t* ,$ (+! n$@*t&)+!
@% C*nt&,*, t+t*( ,$ n/'$#+! $nt#*,+! !&n "+nt*# $( !$nt&n$(
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 438/499
PROBLEMA 2
Programa para "or!ear por edad
D$!*##+(($ un* *p(&"*"&7n u$ ($* ,$ unarchivo (+! !&@u&$nt$! "*'p+! n/'$#+ !$@u#+ !+"&*(6 *p$((&,n+'5#$6 pu$5(+ - $" * ,$ n*"&'&$nt+. G$n$#*n un #$p+#t$ u$ p#$!$nt$ t+,+! (+! "*'p+! - "*("u($ (* p$#!+n*. E( #$p+#t$ !$ )* * &'p#&'&# $n +#,$n ,$ $,*, ,$ '$n+# * '*-+#.
,atos 0el $r+hivo
1111111116 R+,#`@u$86 M*#&!+(6 B*-*'7n6 2 ,$ ,&"&$'5#$ ,$ 1 <2222222226 M*#t`n$86 E,@*#6 D+#*,+6 12 ,$ $n$#+ ,$ 1 :23333333336 G+n8_($86 Hu*n6 D+#*,+6 12 ,$ +"tu5#$ ,$ 1 34444444446 R+,#`@u$86 I)_n6 V$@* B*0*6 2 ,$ $5#$#+ ,$ 1 :2
6 A(+'*#6 R+5$#t+6 S*(&n*!6 1: ,$ 0un&+ ,$ 1 :
PROBLEMA 3
Programa para calcular cuen!a" a cobrar
L* "+'p*9`* ;Y t&$n$ p#+5($'*! "+n (*! "u$nt*! * "+5#*# - (+ "+nt#*t* p*#* ,$!*##+((*# un* *p(&,&@* (+! "(&$nt$! u$ "*nt&,*, ,$ ,&n$#+ ,$5$n * 3< ,`*!6 * :< ,`*! - !+5#$ < ,`*!. T&$n$n u$ ($$*"tu#*6 n+'5#$ ,$ "(&$nt$6 $" * *"tu#* - t+t*( ,$ (* *"tu#*.
E( #$p+#t$ t&$n$ u$ $!t*# +#@*n&8*,+ p+# "(&$nt$ - t&$n$ u$ &n +#'*# (* "*nt&,*, u$ ,$5$ * 3!+5#$ < ,`*!.
#atos del archivo
33433*6 C+'p*9`* ,$ En$#@`*6 2 ,$ '*#8+ ,$ 2<<16 43 3. :43 3:56 E( V+"$#+6 2: ,$ '*#8+ ,$ 2<<16 3423.43 :306 M&"#+!+ t6 : ,$ *5#&( ,$ 2<<16 43 .34
43 32 6 C+'p*9`* ,$ En$#@`*6 2 ,$ '*#8+ ,$ 2<<16: 34.2: 3 3 6 C+'p*9`* ,$ En$#@`*6 2 ,$ *5#&( ,$ 2<<16234 .:3 3 16 E( V+"$#+6 1 ,$ '*-+ ,$ 2<<16 43 :. :
PR:B!$-A +
Programa para recibo de .en!a
Un* "*0$#* n$"$!&t* !*5$# $( "*'5&+ ,$ un* "+'p#* ,$ un p#+,u"t+. E((* )* * $nt#*# (+! n+'5#$! ,$ p#+,u"t+! - !u! #$p$t&,+! p#$"&+! ,$ )$nt*. Lu$@+ u$ !u'$ $( t+t*( ,$ (* )$nt* )* * $nt#*# (* "*nt& p+# $( "(&$nt$. L* *p(&"*"&7n t&$n$ u$ &n +#'*# $( "*'5&+ u$ !$ ($ )* * ,*# *( "(&$nt$ t*nt+ $$n ,7(*#$!. E0$'p(+ !& (* )$nt* t+t*( $! ^12.1< - $( "(&$nt$ ,* un 5&(($t$ ,$ ̂ 2<6 $( "*'5&+ )* * !$,$ ^ 6 ,+! 5&(($t$! ,$ ^16 t#$! p$!$t*!6 un )$((7n ,$ 1< "$nt*)+! - un )$((7n ,$ "$nt*)+!. A,$'_! ,$( t+(* )u$(t*6 ,&!$9$ $( #$"&5+ "+'+ !& u$#* un* t&$n,* p+# ,$p*#t*'$nt+!.
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 439/499
Universidad Interamericana de Puerto RicoRecinto de Bayamón
CO-;2/2NCI"S 2 ;?O<?"-"CI@N'
;remiaciones
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 440/499
.nterAmerican University o7 Puerto RicoBayamón Campus
.n7ormatic and Telecommunications #epartment.n7ormatic 0tudent Association 2.0A<A$.6
.1MP2" R PR1 $MM!N .4$55 N !! &''
CATE+OR : ADHANCED
6!R7" P5$. TEAM NAME L+! M+ +n@+!PARTICIPANTS NAMES Hu*n C. V ($86 Hu*n P*5(+ L$7nEMAIL1 VISUAL STUDIO ENTERPRISE EDITION1 KINDOKS 2<<< PROFESSIONAL
0$C:N# P!AC$TEAM NAME L*! G&#(! S"+utPARTICIPANTS NAMES I!'*$( P(*"*6 M*#`* ,$( M*# ()*#$8EMAIL1 VISUAL STUDIO PROFESSIONAL EDITION1 IBM KEB SPJERE STUDIO
T;.R# P!AC$TEAM NAME 5&t *"t+#- 1<PARTICIPANTS NAMES Eu#`p&,$! R&)$#*6 C*#(+! R$-$!EMAIL $u#&l#&)$#*y +t'*&(."+'6 !+n&"y"+ u&.n$t1 VISUAL STUDIO PROFESSIONAL EDITION1 VISUAL AGE SMALL TAL ENTERPRISE
C"/2<O?E: IN/2?-2 I"/2
6!R7" P5$. TEAM NAME L+! M*##+n$#+!PARTICIPANTS NAMES G$+#@$ G+n8_($86 Lu&! C*#'+$@*EMAIL1 VISUAL STUDIO ENTERPRISE EDITION1 VISUAL AGE FOR HAVA
0$C:N# P!AC$TEAM NAME C-5$# Sp&,$#'*nPARTICIPANTS NAMES J*+ K$& Ku6 D*n&$( D`*8EMAIL1 VISUAL STUDIO PROFESSIONAL EDITION1 BORLAND DELPJI DEVELOPMENT TOOLS
T;.R# P!AC$
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 441/499
TEAM NAME T$'&5($!PARTICIPANTS NAMES E(!&$ M*(*) 6 M-#n* I#&8*##-EMAIL (&!& <y +t'*&(."+'1 VISUAL STUDIO PROFESSIONAL EDITION1 VISUAL BASIC :.< DEVELOPMENT BOO %
C"/2<O?E: ,2<INN2?S
6!R7" P5$. TEAM NAME R$*($! p*#* C#&!t+PARTICIPANTS NAMES n@$( C+(7n6 M*#`* M*##$#+EMAIL "+(+nl*n@$(y +t'*&(."+'6''*#$##+3 1y5".&nt$#.$,u 1 VISUAL STUDIO ENTERPRISE EDITION1 OFFICE 2<<< DEVELOPER
0$C:N# P!AC$TEAM NAME N+ C+,$PARTICIPANTS NAMES K&(!+n D`*86 M*#t&n R$-$!EMAIL -&$(,yp#t".n$t6#$-$!'*#t&n1 y +t'*&(."+' 1 VISUAL STUDIO PROFESSIONAL EDITION1 TJE COMPLETE VISUAL BASIC :.< TRAINING COURSE
T;.R# P!AC$TEAM NAME yWb3^ ..ZPARTICIPANTS NAMES M*-#* V_8 u$86 H+n*t *n N*8*#&+EMAIL '*-#&t*1 y +t'*&(."+' 6 0+!"*#&ny"*#&5$.n$t 1 VISUAL STUDIO PROFESSIONAL EDITION1 KEB APPLICATION DEVELOPMENT USING MS VISUAL INTERDEV :.< BOO %
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 442/499
Universidad Interamericana de Puerto RicoRecinto de Bayamón
CO-;2/2NCI"S 2 ;?O<?"-"CI@N
23pertos
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 443/499
Universidad .nteramericana de Puerto RicoPrimeras :limpiadas de Programación
.NT$RBA 'KKK
CAT$9:R A #$ $OP$RT:
In!t#u""&+n$! @$n$#*($!
T+,+! (+! p#+5($'*! ,$ $!t* "*t$@+#`* !$#_n &nt$#*"t&)+!. NO ($$n ,*t+! ,$!,$ *#" &)+! $ t$#n+!%ut&(&8*# p*#* #$!+()$#(+! (+! !&@u&$nt$! ($n@u*0$! V&!u*( B*!&" + C . D$5$n $nt#$@*#!"+'+ (+ *-*! t$#'&n*,+.
1% C+,$ * p#+@#*' t *t $n*5($! * p$#!+n t+ &nput n*'$!6 p +n$ nu'5$#!6 *n, "*t$@+#&$! F#&$nBu!&n$!!% + *" u*&nt*n"$! '* &'u' + 2 %. Input t $ &#!t n*'$!6 (*!t n*'$!6 *n, p +n$ nu'5$#! t$ t 5+ $!. U!$ +pt&+n 5utt+n! +# t $ "*t$@+#-. K $n t $ u!$# "(&"?! *n A,, t+ L&!t 5utt+n6 t $!t+#$! t $ n*'$6 nu'5$#6 *n, "*t$@+#- &n *##*-6 ,&!p(*-! + '*n- n*'$! *#$ !*)$,6 *n, "($*#! t $ &)*(u$! #+' t $ !"#$$n. A '$!!*@$ (*5$( &! u!$, +# $##+# '$!!*@$! *n, t+ &n,&"*t$ + '*n- n*'$! 5$$n *,,$, t+ t $ *##*-!. K $n t $ u!$# "(&"?! t $ "($*# 5utt+n6 t $ t$ t 5+ $!6 '$!!*@$6 "*t$@+#- 5+ "($*#. K $n t $ u!$# "(&"?! t $ ,&!p(*- (&!t 5utt+n6 *(( t $ )*(u$! #+' t $ *##*-! *#$ ,&!p(*-$(&!t 5+ *t t $ 5+tt+'. D&!p(*- * !p$"&*( '$!!*@$ & D&!p(*- (&!t &! "(&"?$, 5$ +#$ *n- n*'$! **##*-!. A #+u@ (*-+ut + t $ +#' &! ! + n $#$.
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 444/499
2% A (& $ &n!u#*n"$ "+'p*n- *! &#$, -+u t+ #&t$ * p#+@#*' t+ p#&nt * (&!t + t $&# "u!t+'$#! p#$'&u' t *t $*" "u!t+'$# p*-!. P#$'&u'! *#$ 5*!$, &n t $ *@$ "u!t+'$# *! $n $ +# ! $ 5$"*'$ *"u!t+'$#. T $ +((+ &n@ t*5($ &! u!$, t+ ,$t$#'&n$ $*" "u!t+'$#d! p#$'&u'6 5ut t $!$ #*t$! *#$ !t+ " *n@$.
A@$ P#$'&u'2 ^2 .<<3 2 .<<4 3< .<<
32 .<<: 3 .<<
E*" *@$ (&!t$, &n t &! t*5($ &! t $ upp$# (&'&t +# t $ p#$'&u'. F+# $ *'p($6 & * "u!t+'$# !&@n p+(&"- $n ! $ *! 3 6 ! $ +u(, p*- ^3< .
K#&t$ * p#+@#*' t *t #$*,! t $ (&!t + !$ u$nt&*( &($ &nt+ p*#*(($( *##*-!6 t $n #$*,! &n t $ "u!t+*n, *@$! $n t $- 5+u@ t t $ p+(&"&$! &nt+ *n+t $# p*&# + p*#*(($( *##*-!. T $ t*5($ *n, t $ "u!n*'$! *n, *@$! *#$ !t+#$, &n t + &($!. P#&nt +ut * +#'*tt$,6 (*5$($, (&!t ! + &n@ $*" "u!t+'$#d! +# $# *@$ $n t $ p+(&"- *! 5+u@ t6 *n, t $ "u!t+'$#d! p#$'&u'.
3% C+n!&,$# t $ !$ u$n"$ + ,&@&t! #+' 1 t#+u@ N $#$ NX % &n &n"#$*!&n@ +#,$# 1 2 3 4$&t $# * % +# *,,&t&+n +# * >% +# !u5t#*"t&+n +# * % Q5(*n? t+ #un t $ ,&@&t! t+@$t $#$!u(t *n, !$$ &, -+u @$t 8$#+.
K#&t$ * p#+@#*' t *t &(( &n, *(( !$ u$n"$ + ($n@t N t *t p#+,u"$ * ERO SUM.
T$0T CA0$
Input
Output1 2>3 4> >: X<1 2>3>4 :> X<1>2 3 4> :> X<1>2>3>4> : X<1>23 4 : X<1>23>4 : X<
Y+u '*- t$!t t &! p#+@#*' 5- $nt$#&n@ t $ &nt$@$# #+' t $ ?$-5+*#,.4%A t$*" $# '*&nt*&n! * #*n,+'>*""$!! &($ "+nt*&n&n@ t $ +((+ &n@ &n +#'*t&+n +# $*" !tu!+"&*( !$"u#&t- nu'5$#6 @#*,$! +n $*" + t + +u#(- $ *'!6 *n, t $ &n*( $ *' @#*,$. A!!u'$ t $ #*n,*""$!! &($ GRADES.T;T *! 5$$n "#$*t$, &t !t#&n@ &$(,! + ($n@t ! 2 *n, 11 *n, t #$$ nu'$#&" *n, *(( t $ n*'$! *n, !+"&*( !$"u#&t- nu'5$#! *)$ 5$$n $nt$#$,. T $ nu'$#&" &$(,! *)$ 5$$n &n&t&&t 8$#+!. K#&t$ * p#+@#*' &t t $ &)$ "+''*n, 5utt+n! [D&!p(*- F&#!t Stu,$nt\6 [R$"+#, G#*,$D&!p(*- N$ t Stu,$nt\6 [L+"*t$ Stu,$nt\6 [P#&nt G#*,$ L&!t\6 *n, [D+n$\ t+ *((+ t $ t$*" $# t+ ,+ t+((+ &n@.
*% Ent$# *(( @#*,$! +# * !p$"& &" $ *'.
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 445/499
5% L+"*t$ *n, ,&!p(*- t $ #$"+#, +# * !p$"& &" !tu,$nt !+ t *t +n$ +# '+#$ @#*,! '*- 5$ " *n"% P#&nt * (&!t + &n*( @#*,$! t *t "*n 5$ p+!t$,. T $ (&!t ! +u(, ! + t $ (*!t +u# ,&@&t!
!$"u#&t- nu'5$#6 t $ @#*,$ +n t $ &n*( $ *'6 *n, t $ !$'$!t$# *)$#*@$ + $*" !tu,$nt. T $!$'$!t$# *)$#*@$ &! ,$t$#'&n$, 5- t $ +#'u(* $ *'1 $ *'2 2 e &n*( $ *'%b4.
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 446/499
Universidad Interamericana de Puerto RicoRecinto de Bayamón
CO-;2/2NCI"S 2 ;?O<?"-"CI@N
Intermedios
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 447/499
Un&)$#!&,*, Int$#*'$#&"*n* ,$ Pu$#t+ R&"+P#&'$#*! O(&'p&*,*! ,$ P#+@#*'*"&7n
!N" R $% &'''
CAT$9:R A0 #$ .NT$R-$#.:0
Int#u""&+n$! @$n$#*($!
T+,+! (+! p#+5($'*! ,$ $!t* "*t$@+#`* !$#_n &nt$#*"t&)+!. NO ($$n ,*t+! ,$!,$ *#" &)+! $ t$#n+!%ut&(&8*# p*#* #$!+()$#(+! (+! !&@u&$nt$! ($n@u*0$! V&!u*( B*!&" + C . D$5$n $nt#$@*#!$"+'+ (+ *-*! t$#'&n*,+.
PRO#$EMA B
E!"#&5$ un p#+@#*'* u$ p&,* un* "*nt&,*, ,$ ,&n$#+. D*# "+'+ #$!u(t*,+ $( n/'$#+ ,$ p$!$t*!6 ,&)$((+n$! - "$nt*)+! u$ *( !u'*#(+! ,$ (* "*nt&,*, ,$ ,&n$#+ $nt#*,+. D$5$ !$# $( n/'$#+ '`n&'+ ,$ '$nE0$'p(+ "*nt&,*, $nt#*,* ^2.1
R$!u(t*,+
p$!$t* !%1 ,&'$ !%1 )$((7n $!%2 "$nt*)+ !%
PRO#$EMA 4
E!"#&5$ un p#+@#*'* u$ &'p($'$nt$ $ p+n$n"&*"&7n. E( p#+@#*'* p$,&#_ )*(+# p*#* N u$ !$#)*(+# p*#* E u$ !$#_ $( $ p+n$nt$ ,$ N6 *'5+! t&$n$n u$ !$# )*(+#$! $nt$#+!.D$5$ !$@u&# (*! !&@u&$nt$! #$@(*!
Cu*n,+ EZ<X N e N e ..N% E )$"$!Cu*n,+ EX<X1Cu*n,+ Ef<X1b N e N e .N% E )$"$!
eN+ pu$,$ u!*# n&n@un* un"&7n p#$>,$ &n&,*
E0$'p(+ n/'$#+ $nt#*,+ E p+n$nt$ $nt#*,+ 3R$!u(t*,+
R$!u(t*,+ ,$ N $($)*,+ * (* E $! 12
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 448/499
PRO#$EMA 2
E!"#&5&# un p#+@#*'* u$ p&,* (* ,&'$n!&7n "u*,#*,* p*#* +#'*# un* '*t#&8. L* '*t#&8 !$ "#$*n/'$#+! *( *8*# $nt#$ < - . P+n,#_ $n p*nt*((* (* '*t#&8 "#$*,* - *( (*,+ +t#* '*t#&8 u$ $!t*#_ 'u(t p+# 3.E0$'p(+ N/'$#+ $nt#*,+ $! 3 "$#+ p*#* t$#'&n*#%
M*t#&8 M*t#&8 p+# 23 1 4 : 22 2 4 1 4< 3 < : 14
PROBLEMA 4
E!"#&5&# un p#+@#*'* ,$ #$!$#)*"&7n ,$ *!&$nt+! p*#* un *)&7n. E( *)&7n !7(+ t&$n$ 1< *!&!$""&7n ,$ FUMAR - +t#* ,$ NO FUMAR.P$,&# "+n Input $( n+'5#$ ,$( p*!*0$#+ - (* !$""&7n ,$!$*,*.eL+! *!&$nt+! ,$( 1> $! !$""&7n ,$ FUMAR eL+! *!&$nt+! ,$( :>1< $! !$""&7n ,$ NOFUMAR e < !$ ($ *!&@n* *( *!&$nt+ *( &n&"&+ p*#* &n,&"*# u$ $!t_ ,$!+"up*,+ - 1 "u*n,+ $! #$!$#)*,+eN+ pu$,$ #$!$#)*# *!&$nt+! u$ -* $!t n #$!$#)*,+!eCu*n,+ $( p*!*0$#+ ,$!$$ !$""&7n ,$ FUMAR - $!t$ (($n*6 p$#+ (* ,$ NO FUMAR t+,*)`* *- *!& p#$@unt*#($ !& ,$!$* (* +t#* !$""&7n - )&"$)$#!*eCu*n,+ t+,+! (+! *!&$nt+! $!t n +"up*,+! ,*# un '$n!*0$ ,$ u$ $( )u$(+ $!t_ (($n+.eeeD*# "+'+ #$!u(t*,+ "*,* )$8 u$ *-*n #$!$#)*"&+n$!6 $( n+'5#$6 n/'$#+ ,$ *!&$nt+ - !$""&7n F NO FUMAR%eee E( p#+@#*'* ,$5$ "+##$# *!t* u$ !$ (($n$n t+,+! (+! *!&$nt+!.
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 449/499
Universidad Interamericana de Puerto RicoRecinto de Bayamón
CO-;2/2NCI"S 2 ;?O<?"-"CI@N
;rincipiantes
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 450/499
1niversidad Interamericana de ;uerto ?icoP#&'$#*! O(&'p&*,*! ,$ P#+@#*'*"&7n
!N" R $% &'''
CAT$9:R A #$ PR.NC.P.ANT$0
In!t#u""&+n$! @$n$#*($!
T+,+! (+! p#+5($'*! ,$ $!t* "*t$@+#`* !$#_n &nt$#*"t&)+!. NO ($$n ,*t+! ,$!,$ *#" &)+! $ t$#n+!%ut&(&8*# p*#* #$!+()$#(+! (+! !&@u&$nt$! ($n@u*0$! V&!u*( B*!&" + C . D$5$n $nt#$@*#!$"+'+ (+ *-*! t$#'&n*,+.
PRO#$EMA B
E!"#&5$ un p#+@#*'* u$ p+n@* $n p*nt*((* un t#&_n@u(+ !`'5+(+!. E( n/'$#+ ,$ (`n$*! $n $( t#&!`'5+(+ !$#_ $nt#*,+ p+# $( t$"(*,+. D$5$ *!$@u#*#!$ u$ $( n/'$#+ !$* )_(&,+ + !$* u$ !$* '*-+# ,'$n+# ,$ 2 . D$ n+ !$# )_(&,+ ,*# un '$n!*0$ ,$ $##+# - u$ )u$()* * p#$@unt*# *!t* u$ !$* )_(&,+P+# $0$'p(+ !& !$ $nt#* - ed (* !*(&,* !$#_
eeee
eeeeeeeeeeee
eeeeeeeee
PRO#$EMA 4
E!"#&5$ un p#+@#*'* u$ "*("u($ $( &nt$# ! u$ @*n*#_ ,$ un* "*nt&,*, ,$ ,&n$#+ &n)$#t&,*. Dun '$n/ + 5+t+n$! (* "*nt&,*, ,$ *9+! u$ !$#_ $nt#$ 1 - 1<. T*'5& n $!"+@$#_ ,$ un '$n/ + 5+t+n$! "&$nt+ ,$ &nt$# ! *p(&"*5($ u$ !$#_ $nt#$ un x - un 1 x. D$5$ #$p$t&# (+! "_("u(+! *!t* u$ !$ $,$( p#+@#*'*.
E0$'p(+ "*nt&,*, &n)$#t&,* ^1<<< * 2 *9+! * un x $( #$!u(t*,+ !$#_ ^12<<
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 451/499
PRO#$EMA 2
E!"#&5$ un p#+@#*'* u$ !&'u($ un* "u$nt* ,$ , 5&t+ ATJ%. D$5$ p+n$# "+'+ "+n!t*nt$ $( 5*(*n$( p*!! +#, u$ !$#_ nu' #&"+. A( "+'$n8*# (* "+##&,* ,$( p#+@#*'* ,$5$ p$,&#($ $( p*!! +#, - p$#&nt$nt*#(+ !+(*'$nt$ 3 )$"$!6 ,$ n+ $nt#*#(+ "+##$"t+ t$#'&n*# $( p#+@#*'*. S& $( p*!! +#, $! "+un '$n/ "+n (*! !&@u&$nt$! *(t$#n*t&)*!
1. Retiro> p$,&# (* "*nt&,*, - ,*# "+'+ #$!u(t*,+ $( 5*(*n"$ *!t* $( '+'$nt+. D$5$ )$#& &"*# u!+5#$ @&#$ (* "u$nt* ,$ !$# *!` ,*# '$n!*0$ [n+ t&$n$ +n,+! !u &"&$nt$!\ - $( 5*(*n"$.
2. #epósito> p$,&# (* "*nt&,*, ,$ ,$p7!&t+ - ,*# "+'+ #$!u(t*,+ $( 5*(*n"$ ,&!p+n&5($.3. Balance>D*# "+'+ #$!u(t*,+ $( 5*(*n"$.
Lu$@+ ,$ (+! #$!u(t*,+! ,$5$ p#$@unt*# !& ,$!$* *"$# +t#* t#*n!*""&7n + ,$!$* !*(&#.
PRO#$EMA Q
E!"#&5&# un p#+@#*'* u$ p&,* 2 n/'$#+!. p+!&t&)+!6 n$@*t&)+ + "$#+%. D*# "+'+ #$!u(t*,+ '$n!*0$! [#$!u(t*,+ !$#_ p+!&t&)+\6 [#$!u(t*,+ !$#_ n$@*t&)+\ + [#$!u(t*,+ !$#_ "$#+\ p*#* (*! +p'*t$'_t&"*! ,$ 'u(t&p(&"*"&7n - !u'*. NO PODR SUMAR NIMULTIPLICAR LOS NÚMEROS.
E0$'p(+ Ent#$ un p#&'$# n/'$#+>'KEnt#$ !$@un,+ n/'$#+'K
-ultiplicación( resultado ser* negativo0uma( resultado ser* cero
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 452/499
MISCELÁNEOS
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 453/499
Fecha <4b1 b2<<< Nombre de la competencia lllllllllllllllllllllllll Categoría E p$#t+ Universidad UPR BAYAMON .Autor N$((&u, T+##$! Tipo de competencia E(&'&n*t+#&*! .Problema lllll Algoritmos llllllllllllllllllllllllllllllllllllll
CO#O$ DESCRIPTION +ENERATOR
0ource File Name( C:B:9$ 4OOO.nput File Name( 9$N>.4!.B:utput File Name( 9$N>: 4!.B
En un "$nt#+ ,$ "+'put+! "#$*#+n un $,&t+# u$ ,&!$9* un #$p+#t$ p+# p*nt*((* - un* )$8 "#$*,+ @$n$#$ $( "7
p*#* (* ,$!"#&p"&7n ,$( *#" &)+. Tu t*#$* $! "#$*# $( '7,u(+ u$ #$"+@$ $( *#" &)+ "+n $( ,&!$9+ ,$ (* p*nt*((* - @$
&n!t#u""&+n$! ,$ COBOL $n +t#+ *#" &)+.
E0$'p(+
ARC;./: C:N $! F:R-AT: #$! R$P:RT$ #$0CR.PC.:N #$! R$P:RT$
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 454/499
A UC6] 3 6989 9 7U 3JB 364BL 5EC9N'K =E >6I6MKNL 5E 9;'5K =E CLE07E;LLJECL6: VMMA==AIIW P6 E: V BWL
L6CCK7N' CLEC ; CLEC CLEC ;L N7M>E5 >EJK5E N7M>E5 CL 6M' 6J'E5=VBBBBBBW VBBW V BWV , &BBW VBBW' V , &BBW
!1 LE6=9N D1& !" P9C #-"/&
!" P9C #-2*/ Q6 7E 7N9QE5;9=6= =E P7E5'K59CKX&!1 LE6=9N D2& !" P9C #- /&
!" P9C #-1 / Q6 7E 5EC9N'K =E >6I6MKNX&!1 LE6=9N D3& !" P9C #-</&
!" P9C #-1B/ Q6 7E 5E 9;'5K =E CLE07E;X&!1 LE6=9N D$& !" JECL6 P9C #-*/ Q6 7E
JECL6:X&
!" P9C #& !" MKN'L P9C BB& !" P9C # Q6 7E AX& !" =6I P9C BB& !" P9C # Q6 7E AX& !" IE65 P9C BB&!1 LE6=9N D"& !" P9C #-</ Q6 7E
6CCK7N'X&
!" P9C ##& !" P9C #-*/ Q6 7E
CLEC ;X&
!" P9C ##& !" P9C #-"/ Q6 7E
CLEC X&
!" P9C #-11/& !" P9C #-*/ Q6 7E
CLEC ;X&
!1 LE6=9N D*& !" P9C #&
!" P9C #-*/ Q6 7E
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 455/499
N7M>E5X&
!" P9C ##& !" P9C #-*/ Q6 7E
>EJK5EX&
!" P9C ##& !" P9C #-*/ Q6 7E
N7M>E5X&
!" P9C #& !" P9C #-*/ Q6 7E
CL X&
!" P9C #& !" P9C ### Q6 7E
6M'X&
!" P9C ###& !" P9C #-"/ Q6 7E
6J'E5X&
!1 =E'69 D1& !" J9E =D1 P9C -"/&
!" P9C ####&
!" J9E =D2 P9C BB& !" P9C #-"/& !" J9E =D3 P9C B& !" P9C ##& !" J9E =D$ P9C , &BB&
!" P9C ###&!" J9E =D" P9C BB&
!1 'K'6 D1& !" P9C #-22/&
!" P9C , &BB&
T+'$ $n "+n!&,$#*"&7n (+ !&@u&$nt$
1. E( p#&'$# "*#*"t$# ,$( *#" &)+ ,$t$#'&n* $( t&p+ ,$ (&n$* * ,$ &n&#. J X J$*,&n@6 D X D$t*&(6 T X T+t*(%.2. L`n$*! $n 5(*n"+ n+ t&$n$n u$ ,$ &n&#!$.3. L+!string ,$ (+! values )*n $n un* !$@un,* (`n$* &n,$p$n,&$nt$'$nt$ ,$ !u (*#@+ $ "(u-$n,+ $( +#'*t+ ,$ $" *. (+! [b4. E( "7,&@+ t&$n$ u$ @$n$#*#!$ "+n (* '$n+# "*nt&,*, ,$ "*#*"t$#$! p+!&5($!.. L+! n+'5#$! ,$ )*#&*5($! !$ &n"#$'$nt*n *ut+'_t&"*'$nt$.
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 456/499
:. L+! !&@n+! Z - f &n,&"*n &n*( - p#&n"&p&+ ,$ un "*'p+. Cu$nt*n "+'+ $!p*"&+.
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 457/499
Fecha <4b1 b2<<< Nombre de la competencia lllllllll Categoría E p$#t+ Universidad lllllllllllllllllllll Autor N$((&u, T+##$! Tipo de competencia llllllllllllll Problema lllll Algoritmos llllllllllllllllllllll
CO#O$ DESCRIPTION OPTIMI7ER
0ource F ile Name( C:B:PT 4OOO.nput File Name( #$0C>.4!.B:utput File Name( #$0C>: 4!.B
En un "$nt#+ ,$ "7'put+! !$ $n"+nt#*#+n "+n p#+5($'*! ,$ $!p*"&+ $n ,&!"+ $n !u M*&n #*'$ p#&n"&p*(. D$!p
)*#&*! t "n&"*! p*#* (&5$#*# $!p*"&+ $n ,&!"+6 !$ $n"+nt#*#+n "+n $( p#+5($'* ,$ u$ t+,*)`* n$"$!&t*5*n $!p*"&+System
ana#er !u@&#&7 u$ !$ ,$pu#*#*n (*! (&5#$#`*! ,$ (*! ,$ &n&"&+n$! ,$ *#" &)+! ,$ COBOL. E!t+ ,$5&,+ * u$ $( <
$n $!$ ($n@u*0$. D$!*##+(($ un p#+@#*'* u$ ($* ,$ $nt#*,* un* ,$!"#&p"&7n ,$ #$"+#, n&)$( <1% - ($ ,&!'&nu-* (*
"*#*"t$#$! p+!&5($!. E0$'p(+
#$0CR.PC.:N :R.9.NA! #$0CR.PC.:N :PT.-."A#A
!1 5ECK5=D=EJ&!" C6MPKD1 P9C'75E #####&!" C6MPKD2 P9C'75E BBBBB&!" C6MPKD3 P9C BB&
!" C6MPKD$ P9C'75E BBBBBQBB&!" C6MPKD" P9C ####&!" J9 E5 P9C' #-1!/&!" C6MPKD* P9C QBBBBBBB&!" J9 E5 P9C'7 ###&
!1 5ECK5=D=EJ&!" C6MPKD1 P9C #-"/&!" C6MPKD2 P9C B-"/&!" C6MPKD3 P9C BB&
!" C6MPKD$ P9C B-"/QBB&!" C6MPKD" P9C #-$/&!" P9C #-1!/&!" C6MPKD* P9C QB-</&!" P9C ###&
T+'$ $n "+n!&,$#*"&7n (+ !&@u&$nt$
. L+! FILLER !$ $(&'&n*n ,$( "7,&@+ +#&@&n*(.
. PICTURE !$ *5#$)&* * PIC.
. Cu*( u&$# !`'5+(+ ,$ $,&t*0$ '*-+# ,$ 3 p+!&"&+n$! ; 7 % !$ *5#$)&* "+n (* "*nt&,*, ,$ "*#*"t$#$! pu$!t+! $n u"+'&((*!.
1<. S$ t&$n$ u$ "+n!&,$#*# $( !`'5+(+ V.11. S$ ,$5$ '*nt$n$# (* *(&n$*"&7n u$ t#*&@* $( "7@&,+ +#&@&n*(.12. A!u'* u$ $( "7,&@+ n+ t&$n$ $##+#$! ,$ !&nt* &!.13. S+(+ *5#_ un* ,$!"#&p"&7n ,$ #$"+#, p+# *#" &)+.
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 458/499
Fecha <4b1 b<< Nombre de la competencia lllllllllll Categoría E p$#t+ Universidad lllllllllllllllllllllll Autor Hu*n M S+(_ S(+*n Tipo de competencia llllllllllllllll Problema lllll Algoritmos llllllllllllllllllllllll
TCA$ , B CompilerTCA$ Ne"!ed $oop !o 9 8 A""embl% $anguage
A u!t$, !$ ($ * $n"+'$n,*,+ "#$*# p*#t$ ,$( "+'p&(*,+# ,$ TCAL . <1. TCAL $! un ($n@u*0$ ,$#&)*,+ ,$( COBOL u$ !$ p*#* p#+@#*'*# t$#'&n*($! ,$ '*n+ ,$ *('*" n. L* t*#$* u$ !$ ($ * $n"+'$n,*,+ $! "+n)$#t&# un* !$#&$ ,$ "&"(+! "+n " Assembly /an#ua#e ,$ < .
L+! "&"(+! $n A!!$'5(- un"&+n*n ,$ (* !&@u&$nt$ '*n$#* E( #$@&!t#+ C; )* * t$n$# (* "*nt&,*, ,$ )$"$! u$ !$ $0$"C*,* )$8 u$ (* &n!t#u""&7n ,$ LOOP *p*#$8"* $n $( "7,&@+6 C; !$ ,$"#$'$nt*#_ *ut+'_t&"*'$nt$. Un "&"(+ ,$ 1 * 1<un "&"(+ ,$ 1< * 1. E0$'p(+
Ciclos en Assembly
MOV C;61< > Ot#*! &n!t#u""&+n$! )*n * u& >LOOP
L+! "&"(+! *n&,*,+! ,*n p#+5($'* pu$! $( /n&"+ #$@&!t#+ ,$ p#+p7!&t+ @$n$#*( u$ un"&+n* "+n LOOP $! C;. P*#*n&,*,+ un"&+n$ !$ ,$5$ $'pu0*# $( )*(+# ,$ C; $n $( St*"? V *!$ $( $0$'p(+ ,$ *5*0+%.
.nstrucciones de Assembly a utiliQarseP*#* $!t$ p#+@#*'* (*! &n!t#u""&+n$! u$ !$ ut&(&8*#_n !$#_n !u'*6 #$!t*6 &n"#$'$nt+ - ,$"#$'$nt+. En *!!$'5(- ,$ <
INC ; &n"#$'$nt+ ;DEC ; ,$"#$'$nt+ ;SUB ;6Y #$!t* ; > YADD Y6 !u'* Y
In!t#u""&+n ,$ LOOP V *!$ $0$'p(+ ,$ "&"(+ $n A!!$'5(-%
$%emplo del insumo 2TCA!4.N6 Salida &TCA$,O0T'DATA DIVISION.
<1 ; PIC .<1 Y PIC .<1 PIC .PROCEDURE DIVISION.PERFORM VARYING CTR FROM 1 BY 1 UNTIL CTR Z 1<
PERFORM VARYING CTR2 FROM 1 BY 1 UNTIL CTR Z 1<< COMPUTE ; X ; 1END>PERFORMCOMPUTE Y X Y>1
COMPUTE X >;END>PERFORM.PERFORM 2<<>OPENlPORT
STOP RUN.
MOV C;6 1<PUSJ C; MOV C;6 1<< INC ; LOOPPOP C;DEC Y
SUB 6Y
LOOPCALL OPENlPORT.E;IT <END
Nota: L*! &n!t#u""&+n$! ,$ PERFORM 2<<>OPENlPORT - STOP RUN. T&$n$ u!t$, u$ "+(+"*#(*! *( &n*( ,$ !u "7,&A!!$'5(- !&$'p#$ u$ *p*#$8"*n $n $( *#" &)+ ,$ $nt#*,* Su5!t&tu&# p+# CALL OPENlPORT - .E;IT <6 END "+'+ $n $
No apare8eran otros P R61RM a otras rutinas
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 459/499
UN./$R0.#A# #$ PU$RT: R.C:A#-.N.0TRAC.:N #$ C:!$9.:0 R$9.:NA!$0
C:!$9.: UN./$R0.TAR.: T$CN:!:9.C: #$ BA A-:N#$PARTA-$NT: #$ C:-PUTA#:RA0
C:-P$T$NC.A0 #$ $!.-.NAT:R.ACAT$9:R.A PR.NC.P.ANT$
PRO#$EM X B, CAPS
.NPUT F.!$ NA-$( B$9#./&4#AT:UTPUT F.!$ NA-$ B$9#./&4:UT
PR:B!$-(
Ut&(&8$ $( *#" &)+A0C.. B$9#./&4#AT u$ $!t* &n"(u&,+ $n $( ,&!"+ u$ !$ $nt#$@+ - $( "u*(* !&@u&$nt$ &n +#'*"&7n
Universidad de Puerto RicoAdministracion de Colegios RegionalesColegio Universitario Tecnologico de Bayamon
N+ !$ ut&(&8*n (+! *"$nt+! p*#* $!t$ p#+5($'*. J*@* un p#+@#*'* u$ "*'5&$ (*! ($t#*! '&'*-/!"u(*! - )&"$)$#!* - (+ @u*#,$ $n $( *#" &)+B$9#./&4:UT . S$ pu$,$ ut&(&8*# "u*( u&$# un"&7,$ &n&,* u$ "+nt$n@* $( ($n@u*0$ p*#* "+n)$#t&# (*! ($t#*!.
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
PRO#$EM X 4, C5ARACTER TO ASCCII TO C5ARACTER A+AIN
.NPUT F.!$ NA-$( B$9#./&4#AT:UTPUT F.!$ NA-$( B$9#./'4:UT:UTPUT F.!$ NA-$( B$9#./'A4:UT
PR:B!$-(
Ut&(&8*n,+ $( *#" &)+ ,$ $nt#*,* ,$( p#+5($'* *nt$#&+#6 *@* un p#+@#*'* u$ "#B$9#./'4:UT %6 $( "u*( "+n)&$#t* $n "$#+!K% - un+!&% (+! "*#*"t$#$!6 ut&(&8*n,+ $( "7,&@+A0C.. &n"(u`
$n $!t*! +0*!% ,$( *#" &)+B$9#./&4#AT . En +t#*! p*(*5#*! !$ !u!t&tu&#_ "*,* ($t#* p+# +" +!&'u(*n,+ $( "7,&@+ 5&n*#&+A0CC.. . Un* )$8 $( *#" &)+ B$9#./'4:UT % $!t$ "#$*,+6 $( p#+@#*'* p#* ($$#(+ "+'+ *#" &)+ ,$ $nt#*,* "$##*#(+ p#&'$#+% - (+ )+()$#_ * "+n)$#t&# $n un *#" &)+ ,$ "A0C..((*'*,+ B$9#./'A4:UT4
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 460/499
PRO#$EM X 2, P5ONE CODE
.NPUT F.!$ NA-$( N:N$:UTPUT F.!$ NA-$ N:N$
PR:B!$-(
L+! n/'$#+! t$($ 7n&"+! t&$n$n un* !$#&$ ,$ ($t#*! *!&@n*,*! (*! "u*($! !+n
&X N+ t&$n$ ($t#*! *!&@n*,*!
' XA B C
=X# $ F
+X9 ; .
X8 D !
, X- N :
XP R 0
LXT U /
VX@ O
KX N+ t&$n$ ($t#*! *!&@n*,*!
C#$$ un p#+@#*'* u$ p&,* ,$ &n!u'+ un n/'$#+ t$($ 7n&"+ ,$ !&$t$ ,&@`t+! &n"(u-$n,+ $( _#$* "+,$. E( p#+@#*'* '+!t#*#_ $n (* p*nt*((* $( n/'$#+ "+n)&#t&$n,+ (*! ($t#*! u$ t$n@* $n n/ p#+@#*'* t&$n$ u$ )*(&,*# $( ,*t+ ,$ $nt#*,*
&4 u$ $ &!t*n L "*#*"t$#$! &n"(u-$n,+ @u&7n%. '4 u$ $( @u&7n $ &!t* - $!t $n (* p+!&"&7n "+##$"t*.
=4 u$ n+ $ &!t* n&n@/n +t#+ "*#*"t$# $!p$"&*( *p*#t$ ,$( @u&7n6 ($t#*! - n/'$#+!+4 N+ !$ ut&(&8*n (*! ($t#*!E - " p+# (+ u$ !& !+n &n"(u&,*!6 $( p#+@#*'* ,$5$ &n,&" $!*! ($t#*! n+ !+n )_(&,*!.
0A-P!$ .NPUT < :UTPUT(
.NPUT( >CASJ :UTPUT( >22 4
.NPUT( TJE>BEST :UTPUT( 43>23
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 461/499
PRO#$EM X Q, DA O* T5E 6EE
.NPUT F.!$ NA-$( N:N$:UTPUT F.!$ NA-$( N:N$
PR:B!$-(J*@* un p#+@#*'* u$ "*("u($ $( ,`* ,$ un* $" * $n p*#t&"u(*# u$ p+# (+ '$n+! $!t $n $( !&
p#+@#*'* #$"&5&#_ ,$ $nt#*,* un* $" * "+n $( +#'*t+--<##< . J*- u$ )*(&,*#
1. u$ (* $" * $!t$ "+##$"t*.2. u$ n+ !$* '$n+# ,$ &VK& n& '*-+# ,$&VVV.3. L+! ,`*! - (+! '$!$!. E0. N+ $ &!t$ un 3< ,$ $5#$#+%4. S& pu$,$ )*(&,*# un *9+ 5&!&$!t+6 $!t+ !$ "+n!&,$#*#_ *( '+'$nt+ ,$ $)*(u*# (* "*nt&,*, ,$ p#+5($'*! u$ #$!+()&7 $( $!tu,&*nt$.
0A-P!$ .NPUT < :UTPUT(.NPUT( <3b<1b ::UTPUT( VIERNES
.NPUT( <:b31b ::UTPUT( INCORRECT DATE>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
PRO#$EM X , TE-T INHERTER
.NPUT F.!$ NA-$( N:N$:UTPUT F.!$ NA-$ N:N$
PR:B!$-(
J*@* un p#+@#*'* u$ *"$pt$ ,$ $nt#*,* un !t#&n@ ,$ "*#*"t$#$! - (+! &n)&$#t*.Para resolver esteproblema no se puede utiliQar ninguna 7unción e5istente en el lengua%e Gue haga este proceso4 E( p#+@#*'*tiene u$ '*n$0*# $( !t#&n@ p+# "*#*"t$#$! - n+ p+,#_ *"$pt*# '_! ,$ 2< "*#*"t$#$! "+n!$ N+ !$ )* * ut&(&8*# $( $!p*"&+ $n 5(*n"+ "+'+ un "*#*"t$# $nt#$ (+! u$ !$ )*n * &n)$#t&#. J*-
&4u$ $( !t#&n@ n+ !$* '*-+# ,$'K n& '$n+# ,$' .
'4 u$ (+! "*#*"t$#$! * ut&(&8*#!$ !$*n ,$ (*A>" '&n. - '*-. - (+! n/'$#+! ,$( K *(V.0A-P!$ .NPUT < :UTPUT(
.NPUT( ARRO:UTPUT( ORRA
.NPUT( ROMA:UTPUT( AMOR
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 462/499
Fecha llllbllllbllll Nombre de la competenciaCategoría PRINCIPIANTES Universidad UPR PROGRAMMINGAutor lllllllllllll Tipo de competencia $(&'&n*t+#&*Problema 1 Algoritmos
T.TU!: #$! PR:B!$-A
0ource File Name( OOOOOOOO4OOO.nput File Name( OOOOOOOO4OOO:utput File Name( OOOOOOOO4OOO
PR:B!$-A0 PARA $!.-.NAT:R.ACAT$9:R.A( PR.NC.P.ANT$0
PRO#$EMA XB
E!"#&5* un p#+@#*'* u$ ($* ,$( u!u*#&+ "&$#t* "*nt&,*, ,$ '$,&,*! $n @*(+n$!6 un* * (* )$86 - )*(+# * (&t#+! *nt$! ,$ p$,&# $( p#7 &'+ )*(+#. L* "*nt&,*, ,$ "+n)$#!&+n$! * #$*(&8*# !$#_ $ntL* "+n)$#!&7n #$ u$#&,* $!litros =4 L _9alones . L&'&t$ !u #$!pu$!t* * ,+! 2% (u@*#$! ,$"&'*($!. At$#'&n*# (* "+##&,*6 ,$5$ )$#& &"*# !& $( u!u*#&+ ,$!$* #$p$t&# $( p#+"$!+a
$8$-P!: #$ !A C:RR.#A(In,& u$ $( n/'$#+ ,$ "+n)$#!&+n$! * #$*(&8*# 3
In,& u$ $( )*(+# 1 * "*("u(*# 1<1< @*(+n$! $ u&)*($n * 3 . (&t#+!
In,& u$ $( )*(+# 2 * "*("u(*# 1313 @*(+n$! $ u&)*($n * 4 .21 (&t#+!
In,& u$ $( )*(+# 3 * "*("u(*# @*(+n$! $ u&)*($n * 2:.4 (&t#+!
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 463/499
Fecha llllbllllbllll Nombre de la competenciaCategoría PRINCIPIANTES Universidad UPR Autor lllllllllllll Tipo de competencia $(&'&n*t+#&*Problema ll2 Algoritmos
PRO#$EMA X4
E!"#&5* un p#+@#*'* u$ ($* un *#" &)+ ,$ t$ t+ "+,&@+.&n%6 - "+n)&$#t* !u "+nt$n&,+ *( "7"+nt&nu*"&7n A > d6 B > d6 C X dWd6 D = yd6 E X d6 F X d6 G X d6 J = xd6 I X fd6 HZd6 M = ed6 N X bd6 O X cd6 P X Q 6 X m 6 R X d6 S X 6 T X %d6 U X d6 V = ld6 K X X Xd
L* "+n)$#!&7n ,$( t$ t+ * !t$ "7,&@+6 ,$5$ *p*#$"$# $n +t#+ *#" &)+ "+,&@+."+,%. Lu$@+"+nt$n&,+ ,$( *#" &)+ $n "7,&@+ "+,&@+."+,% * t$ t+ - $!"#&5&#(+ $n +t#+ *#" &)+ "+,&@+*#" &)+! $n t$ t+6 *p*#$"$#_ $n ($t#*! '*-/!"u(*! /n&"*'$nt$. E( +#'*t+ ,$( t$ t+ ,$5$ !$# $( '&!
*#" &)+ ,$ $nt#*,* "+,&@+.&n% - $n $( *#" &)+ ,$ !*(&,* "+,&@+.+ut%.
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 464/499
Fecha llllbllllbllll Nombre de la competenciaCategoría lp#&n"&p&*nt$! Universidad UPR Autor lllllllllllll Tipo de competencia $(&'&n*t+#&*!Problema 3 Algoritmos
PRO#$EMA X 2
E!"#&5* un p#+@#*'* u$ ($* $( u!u*#&+ 1< )*(+#$! $nt$#+!6 - (+! @u*#,$ $n un *##$@(+ ,$ un$( p#+@#*'* ,$5$ &n,&"*# "u*( ,$ $!+! )*(+#$! $! $( )*(+# '_ &'+6 - "u*( $! $( )*(+# '`n&'+.
$8$-P!: #$ C:RR.#A
E!"#&5* 1< )*(+#$! $nt$#+! !$p*#*,+! p+# un $!p*"&+23 12 1 4 3 2 3 3 <
E( )*(+# '_ &'+ ,$ $!$ @#up+ $! <E( )*(+# '̀ n&'+ ,$ $!$ @#up+ $! 2
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 465/499
Fecha llllbllllbllll Nombre de la competenciaCategoría p#&n"&p&*nt$! Universidad UPR Autor lllllllllllll Tipo de competencia $(&'&n*t+#&*!Problema 4 Algoritmos
PRO#$EMA XQ
E!"#&5* un p#+@#*'* u$ "*("u($ $ &'p#&'* $n p*nt*((* (* "*nt&,*, ,$ ,&n$#+ ,&!p+n&5($ $n un*$n (* "u*( &n&"&*('$nt$ !$ ,$p+!&t7 un* "*nt&,*, ,*,* ,$ ,&n$#+ (* "u*( !$#_ $nt#*,* p+# $( u!u*un* t*!* ,$ &nt$# ! ,$( x . E( p#+@#*'* ,$5$ p+,$# "*("u(*# $!t$ )*(+# ,*,* un* "*nt&,*, ,$ *9+! ($nt#*,* p+# $( u!u*#&+%. U!$ (* #$(*"&7n ,$ u$ $( ,&n$#+ $n (* "u$nt* *( &n*( ,$ un *9+6 $! "u$nt* *( p#&n"&p&+ ,$( *9+ '_! .< )$"$! $( ,&n$#+ $n (* "u$nt*.
$8$-P!: #$ C:RR.#A(
Ent#$ (* "*nt&,*, ,$ ,&n$#+ ,$p+!&t*,+ $n (* "u$nt* 1<<<.<<Ent#$ (* "*nt&,*, ,$ *9+! u$ ,$!$* "*("u(*# 3
A9+1 ^ 1< <.<<A9+ 2 ^ 11::.4<A9+ 3 ^ 12 . 1
P#+"$!+ T$#'&n*,+
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 466/499
Universidad de Puerto RicoAdministración de Colegios Regionales
Colegio Universitario Tecnológico de Bayamón
A4C4C4A!+"&*"&7n ,$ C&$n"&*! ,$ C+'put*,+#*!%
2< ,$ '*#8+ ,$ 1
*O+0EO DE PRO+RAMACI<N
Problem &(
Tu#t($ G#*p &"!% T $ L+@+ (*n@u*@$6 &" &! p*#t&"u(*#- p+pu(*# *'+n@ p$#!+n*( "'*,$ t $ "+n"$pt + tu#t($ @#*p &"! *'+u!. I'*@&n$ * '$" *n&"*( tu#t($ t *t *(?! *#+un, t $ #++' un,"+nt#+( + * C p#+@#*'. T $ tu#t($ +(,! * p$n &n +n$ + t + p+!&t&+n!6 up +# ,+ n. K &($ t $ p$ntu#t($ t#*"$! +ut ! *p$! *! &t '+)$! &($ t $ p$n &! up6 t $ tu#t($ '+)$! *5+ut #$$(- &t +ut #&t&n@In t &! p#+5($' -+u &(( !&'u(*t$ t $ +p$#*t&+n + t $ tu#t($ *n, "#$*t$ * "+'put$#&8$, !?$t" p*, *! $
U!$ * >5-> < *##*- (++# &" &! &n&t&*(&8$, t+ 8$#+!. R$*, "+''*n,! #+' *n *##*- t *t "+t $'. $$p t#*"? + t $ "u##$nt p+!&t&+n + t $ tu#t($ *t *(( t&'$! *n, $t $# t $ p$n &! "u##$nt(- up +A!!u'$ t *t t $ tu#t($ *( *-! !t*#t! *t p+!&t&+n <6< + t $ (++# &t &t! p$n up. T $ !$t + tu#t($ "+''* p#+@#*' 'u!t p#+"$!! *#$ *! +((+ !
Command -eaning
1 P$n up2 P$n ,+ n3 Tu#n #&@ t4 Tu#n ($ t
M+)$ +# *#, 1< !p*"$!+# * nu'5$# +t $# t *n1<%
: P#&nt t $ <>5-> < *##*-En, + ,*t* !$nt&n$(%
Supp+!$ t *t t $ tu#t($ &! !+'$ $#$ n$*# t $ "$nt$# + t $ (++#. T $ +((+ &n@ [p#+@#*'\ +u(, ,#* p#&nt * 12>5-12>! u*#$
26 1236 1236 1236 121
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 467/499
:
A! t $ tu#t($ '+)$! &t t $ p$n &t ,+ n6 !$t t $ *pp#+p#&*t$ $($'$nt! + *##*- (++# t+ 1!. K $n t $ :"+''*n, p#&nt% &! @&)$n6 $#$)$# t $#$ &! * 1 &n t $ *##*-6 ,&!p(*- *n *!t$#&!?6 +# !+'$ +t $# " ++!$. K $#$)$# t $#$ &! * 8$#+ ,&!p(*- * 5(*n?. K#&t$ * C p#+@#*' t+ &'p($'$nt t $ tu#t($ @#*"*p*5&(&t&$! ,&!"u!!$, $#$. K#&t$ !$)$#*( tu#t($ @#*p &"! p#+@#*'! t+ ,#* &nt$#$!t&n@ ! *p"+''*n,! t+ &n"#$*!$ t $ p+ $# + -+u# tu#t($ @#*p &"! (*n@u*@$.
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 468/499
$OP$RT #./.0.:N
DIRECTOR $ISTIN+ COMMAND SIM0$ATOR
Problem '(D$)$(+p * p#+@#*' t *t !&'u(*t$ * @$n$#&"#.R "+''*n,. T $ &nput &(( 5$ #$*, #+' *n &nput &($
n*'$, #.R4TOT. T $ " *#*"t$#! *((+ $, &n t *t &($ &(( 5$
1. A ,+t .% t+ !$p*#*t$ t $ &($ n*'$ *n, t $ $ t$n!&+n +pt&+n*(%.2. C *#*"t$#! #+' A t+ Upp$# *n, L+ $#"*!$ &(( 5$ *((+ $,%.3. Nu'5$#! #+' < t+ .
T $ p#+'pt "+''*n, &(( *((+ t $ +((+ &n@ " *#*"t$#!
1. A ,+t .% +pt&+n*(%2. An *!t$#&!? e% t+ !u5!t&tut$ +n$ +# '+#$ " *#*"t$#!.3. A u$!t&+n '*#? h% t+ !u5!t&tut$ +n(- +n$ " *#*"t$#.
T $ +((+ &n@ *#$ $ *'p($! + )*(&, "+''*n,!.
DIReA.E;E6 DIR ABe.COM6 DIR AhBhCh.DAT6 DIR ABChJe.e6 DIR JELP6 DIRe.e6 DIR .hhh6 DIReAhB.e
T $ #u($! +# &($n*'$! &(( 5$ t $ !*'$ u!$, +# MS>DOS. At t $ $n, t $ p#+@#*' &(( ,&!p(*-t+t*(! + &($! ,&!p(*-$, +n !"#$$n *n, t $ t+t*( + &($! #$*, +n t $ &($. R$'$'5$#6 t $ p#+@#*' 'u!t!$n!&t&)$.0ample :utput(
C:--AN# DIRe.E;EABC.E;EFINISJ.E;EPROGRAM.E;ETEST.E;E
T+t*( &($! #$*, 2 %. T+t*( &($! !$($"t$, 4%.
C:--AN# ZDIReJ.eFINISJ.E;EASJ.T;T
T+t*( &($! #$*, 2 %. T+t*( &($! !$($"t$, 2%.
C:--AN# ZDIR AhBhCe.e N+t &($! +un,
T+t*( &($! #$*, 2 %. T+t*( &($! !$($"t$, <%.
C:--AN# ZDIR AhCe.eABC.E;EA;CTOT.BAT
T+t*( &($! #$*, 2 %. T+t*( &($! !$($"t$, 2%.
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 469/499
Universidad de Puerto RicoAdministración de Colegios Regionales
Colegio Universitario Tecnológico de Bayamón
A4C4C4A!+"&*"&7n ,$ C&$n"&*! ,$ C+'put*,+#*!%
2< ,$ '*#8+ ,$ 1
*O+0EO DE PRO+RAMACI<N
Problem =(
T+ $#! + J*n+&% E)$#- 5u,,&n@ "+'put$# !"&$nt&!t 'u!t @#*pp($ &t "$#t*&n "(*!!&" p#t $ T+ $#! + J*n+& !$$ F&@. .1 % &! +n$ + t $ '+!t *'+u! + t $!$. L$@$n, *! &t t *t &n * t$'p($E*!t6 p#&$!t! *#$ *tt$'pt&n@ t+ '+)$ * p$@ *n, *##*n@$, #+' 5+tt+' t+ t+p 5- ,$"#$*!&n@ !&8$.
*tt$'pt&n@ t+ '+)$ t $ !t*"? #+' t &! p$@ t+ * !$"+n, p$@ un,$# t $ "+n!t#*&nt! t *t $ *"t(- +n$ ,&!?*t * t&'$6 *n, *t n+ t&'$ '*- * (*#@$# ,&!? 5$ p(*"$, *5+)$ * !'*(($# ,&!?. A t &#, p$@ &! *)*&(*5t$'p+#*#&(- +(,&n@ t $ ,&!?!. Supp+!$,(- t $ +#(, &(( $n, $n t $ p#&$!t! "+'p($t$ t $&# t*!?6 !+ t(&tt($ &n"$nt&)$ +# u! t+ *"&(&t*t$ t $&# $ +#t!.
L$t u! *!!u'$ t *t t $ p#&$!t! *#$ *tt$'pt&n@ t+ '+)$ t $ ,&!?! +#' p$@ 1 t+ p$@ 3. K$ &! t+*n, *(@+#&t ' t *t &(( p#&nt t $ p#$"&!$ !$ u$n"$ + ,&!?>t+>,&!? p$@ t#*n! $#!.
I $ $#$ t+ *pp#+*" t &! p#+5($' &t "+n)$nt&+n*( '$t +,!6 $ +u(, #*p&,(- &n, +u#!$()$!+p$($!!(- ?n+tt$, up &n '*n*@&n@ t $ ,&!?!. In!t$*,6 & $ *tt*"? t $ p#+5($' &t #$"u#!&+n &n '&&''$,&*t$(- 5$"+'$! t#*"t*5($. M+)&n@ ,&!?! "*n 5$ )&$ $, &n t$#'! + '+)&n@ +n(- n>1 ,&!?! *n,
#$"u#!&+n% *! +((+
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 470/499
FOGUEO CUTBCortesía de: Nelliud D. Torres
Marzo 20, 1998
EXPERT DIVISION
TECO EDITOR :
Problema:
TECO rue un editor de texto famoso que se usó mayormente en la computadora PDP-10 de la compañíaDIGITAL. E1 motivo principal de utilizar un editor que trabaje por líncas era debldo a los teletipos queimprimían en papel. Estos teletipos funcionaban igual que un terminal, incluso utilizaban un tecladoprácticamente igual a de las computadoras de hoy en día. Sin embargo tenían la desventaja de que no podíanmanejar pantalla, ya que no se puede controlar esas funciones en papel. De esa necesidad surge TECO el cualpermite que se pueda editar un archivo de texto sin la capacidad de manejo de pantalla.
Los comandos de TECO son a base de caracteres y su delimitador es el signo de dó1ar ($). Un signo dedólar significa una separación entre un comando y otro; dos signos de dó1ar ($$) le indica al editor que tieneque ejecutar los comandos dados por el usuario. A continuación una exphcación de los comandos másutilizados: ,!
/ 1. J - E1 comando "J" le indica a TECO movimiento en el texto. Las dos formas de utilizarlo para las
competencias son las siguientes:a. BJ - Mueve' el pointer al principio del buffer.b. ZJ - Mueve el pointer al final del buffer.
2. L - Mueve el poiter al principio de la línea que el usuario indique. Por ejemplo:*. 0L - Se mueve al principio de la línea en que se encuentre el pointer.b. 5L - Se mueve cinco líneas hacia adelante y pone el pointer al principio de la
quinta linea.c. -1L - Mueve el pointer una línea hacia atrás y coloca el pointer al principio de la
línea. Es 1o mismo que L.
3. C - Mueve el pointer "n" cantidad de caracteres. Por ejemplo:*. C > Mu$)$ $( p+&nt$# un "*#*"t$# * (* ,$#$" *. E! (+ '&!'+ u$ 1C. 5 3C > Mu$)$ $( p+&nt$# t# ! "*#*"t$#$! * (* ,$#$" *.".>1C > Mu$)$ $( p+&nt$# un "*#*"t$# * (* &8 u&$#,*.
En "*!+ ,$ u$ !$ &nt$nt$ '+)$# $( p+&nt$# * (* &8 u&$#,* - -* $!t$ (+"*(&8*,+ * (* &8 u(`n$*6 n+ !$ $n)&*#_ '$n!*0$ ,$ $##+# - !$ ,$0* $( p+&nt$# $n $!* p+!&"&7n
4. T > D$!p(&$@* (* (&n$* $n ,+n,$ $!t$ (+"*(&8*,+ $( p+&nt$# + * p*#t&# ,$ $!* (+"*(&8E0$'p(+!*. T D$!p(&$@* (* (`n$* $n ,+n,$ $!t* $( p+&nt$#.
5. OT > D$!p(&$@* $( t$ t+ "+##&,+ ,$!,$ $( p#&n"&p&+ ,$( 5u $# *!t* ,+n,$ !$$n"u$nt#$ $( p+&nt$#.
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 471/499
c. 5T - Muestra las próximas cinco líneas comenzando en la línea en donde este el pointer.d. HT - Muestra en pantalla todas la líneas del buffer.
5. I - Inserta texto entre las líneas a partir de la localización del pointer. Ejemplo:
Itexto a inclur$ - Inserta el string "texto a incluir".
6. K - Se utiliza para eliminar líneas o texto a partir del pointer. Ejemplos:a. K - Elimina texto a partir de la localización del pointer hasta el final de la línea.b. Si el pointer estaba al principio, se dejará la línea en blanco.c. OK - Elimina texto desde el principio de la línea hasta el pointer.
5K - Elimina las próximas 5 líneas a partir de donde se encuentre el cursor.Recuerde que si el cursor esta al principio de la línea, esa primera línea debe quedar en blanco.
7. D - Se utiliza para eliminar caracteres a partir de la localización del pointer. Ejemplos:
*. D - Elimina el primer caracter que este a la derecha del pointerb. 5D- Elimina los pr6ximos 5 caracteres a la derecha del pointer.c. -2D - Elimina los dos caracteres que estén a la izquierda del pointer. Si el
pointer está al principio de la línea, no se elimina nada y no se envía"~' mensaje de error.
8. EX- Guarde el texto y sale de editor~ El formato es: EX$$
Para comenzar a correr la aplicacón se invocará el siguiente comando: TECO texfile.txt. El archivo yadebe existir ya que para simplificar el problema, el editor no tiene que erear un archivo de la nada, Pararepresentar el pointer, se utilizará el asterisco. Recuerde que hasta que no se incluya el comando "T", TECO nodespliega las líneas. Cualquier comando que se salga del rango, el editor lo ignora y no lo ejecuta. AContinuación un ejemplo de como debe trabajar el editor: (Las áreas subrayadas son el output del editor el elresto son comandos de usuario)
e:>TECO programa.txt*0LT$$*IDENTIFICATION DIVISION*HT$$*IDENTIFICATION DIVISION
PROGRAM ID. PRUEBAENVIROMENT DIVISION
STOP RUN*2LT$$*ENVIRONMENT DIVISION.
*5C$3D$0LT$$ENVIR*ENT DIVISION.
IONM^<LT^^ENVIReONMENT DIVISION.
eE;^^C.
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 472/499
Universidad de Puerto RicoAdministración de Colegios Regionales
Colegio Universitario Tecnológico de Bayamón
A.C.C(Asociación de Ciencias de Computadoras)
20 de marzo de 1998 FOGUEO DE PROGRAMACIÓN
Intermediate
Problem B · Hotel Reservation
Write an interactive program to manipulate a database. This database manages the hotel reservations.
The hotel has 6 rooms, from room 101 to room 106. Room numbers ending in odd numbers are single
rooms. Rooms ending in even numbers are double. The program must read: Name, Number of guests,
Date of Entry.
Display a menu with the following Options:
1. Reservation \ Check-In2. Room Status3. Checkout4. Statistics5. Exit Program
Option 1: Access to make a Reservation or Check-InOption 2: Displays the room status (Occupied, Vacant)Option 3: Reads the date a guest leaves.Option 4: Indicates number of times each room has been occupied Option 5: duh!
The program should validate for the correct number of people in each room an that theroom isn't occupied. Also validate the exit date-
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 473/499
Universidad de Puerto RicoAdministración de Colegios Regionales
Colegio Universitario Tecnológico de Bayamón
A.C.C(Asociación de Ciencias de Computadoras)
20 de marzo de 1998 FOGUEO DE PROGRAMACIÓN
Intermediate
Problem 4 : Plot Functions
Write a program that plots polynomial functions.
Input:order, coefficients and constant
Output: (Graph)
Range of:x = 1 to 70y = 1 to 20
Example: (Input)Order: 3Coefficients:
Coefl: 4Coef2:-2Coef3:2
Constant: 4
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 474/499
Universidad de Puerto RicoAdministración de Colegios Regionales
Colegio Universitario Tecnológico de Bayamón
A.C.C(Asociación de Ciencias de Computadoras)
20 de marzo de 1998 FOGUEO DE PROGRAMACIÓN
Intermediate
Problem 2 · Factorials
Write a program that finds the factorial number to any number within I and 25. Validate the input for the
range. To exit the program enter X.
Example 1:
Input:
Enter the number: 3
Output:
Factorial of 3! = 6
Example 2:
Input:
Enter the number: 25
Output:
Factorial of 25! = 15511210043300000000000000
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 475/499
Universidad de Puerto RicoAdministración de Colegios Regionales
Colegio Universitario Tecnológico de Bayamón
A.C.C(Asociación de Ciencias de Computadoras)
20 de marzo de 1998 FOGUEO DE PROGRAMACIÓN
Intermediate
Problem Q: Equal to Zero
Read a sequence of digits from I to N (where N <= 9) in increasing order:
I 2 3 4 5...N
Insert either a + (for addition) or a - (for substraction) between each of the digits so that the resultant
sum is zero.Diaplay all possible combinations that sums zero.
Example:
Input:Number = 7
Output:1+2-3+4-5-6+7=0
1+2-3-4+5+6-7=0
1-2+3+4-5+6-7=0
1-2-3-4-5+6+7=0
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 476/499
Universidad de Puerto RicoAdministración de Colegios Regionales
Colegio Universitario Tecnológico de Bayamón
(Asociación de Ciencias de Computadoras)
20 de marzo de 1998
FOGUEO DE PROGRAMACIÓN Beginners
Problem B: Distance, Midpoint and Slope
Write a program that reads two points, (XI, Y1) and (X2, Y2), from a user and find:
a) the distance between the points
b) the midpoint of the line segment
c) the slope of the line trace from one point to another(If not defined indicate so):
d) the ecuation in the form point-slope
#istance Formula
, P16 P2%X ;1>;2% 2 Y1>Y2% 1b2%
-idpoint Formula(
;1 ;2%b26 Y( Y2%b2
0lope(
'X Y2>Y(% b ;2>;I%
D&!p(*- t $ ,&!t*n"$!6 t $ '&,p+&nt6 t $ !(+p$ *n, t $ $"u*t&+n.
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 477/499
Universidad de Puerto RicoAdministración de Colegios Regionales
Colegio Universitario Tecnológico de Bayamón
(Asociación de Ciencias de Computadoras)
20 de marzo de 1998 FOGUEO DE PROGRAMACIÓN
Beginners
Problem 4 : Draw Shapes
Write a program that draws different shapes at random.
Example:
Input:Enter number of shapes: 5
Output:
Screen
A.C.C
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 478/499
PROBLEMA #5
Escribe un programa que utilizando funciones de gráficos dibuje una pelotita, la cual seguirá la moción indicadaen el próximo dibujo.
Nota: la pelotita no puede salir del margen de la pantalla, y la misma debe estar lo más cercano al bordeposible.
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 479/499
Universidad de Puerto RicoAdministración de Colegios Regionales
Colegio Universitario Tecnológico de Bayamón
A.C.C(Asociación de Ciencias de Cmputadoras)
20 de marzo de 1998 FOGUEO DE PROGRAMACIÓN
Beginners
Problem 2 : File Management
Write a program that reads from one file and writes to another file.
Read from the inventory file (Invent. in) and read all the data of the items that begin with 10 and store in
another file (Invent. out). Give indications to the user that the program, is Reading, Writing, Thinking and
Done. At the end display how many items were moved.
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 480/499
Universidad de Puerto RicoAdministración de Colegios Regionales
Colegio Universitario Tecnológico de Bayamón
A.C.C(Asociación de Ciencias de Cmputadoras)
20 de marzo de 1998 FOGUEO DE PROGRAMACIÓN
Beginners
Problem Q: Ardes Labels
Write a program that reads an address and displays on the screen in proper order.
Example:
Input: John H. Doe, Hc-02 Box 3769, Levittown, P.R, 00943
Output:
Doe, J.H.
Hc-01 Box 3769
Levittown, PR 00943
The name used will consist of a first name, middle initial and last name (In that order) and then
prints the last name, followed by a comma and the first AND middle initial, each followed by a period.
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 481/499
Universidad de Puerto RicoAdministración de Colegios Regionales
Colegio Universitario Tecnológico de Bayamón
A.C.C(Asociación de Ciencias de Computadoras)
21 de febrero de 1998
Competencias: Estudiantes de Nuevo lngreso
Ejercicio #1:
Una compañía desea transmitir data a través de las líneas telefónicas, pero su preocupación es que lainformación sea interceptada indebidamente por otras entidades. Toda su data es transmitida en forma de
enteros de cuatro (4) dígitos. Dicha compañía ha solicitado sus servicios para crear un programa que codifique
su data para que su transmisión sea más segura.
Su programa debe leer un entero de cuatro(4) dígitos y codificarlo utilizando la siguiente formula:
cambie cada digito a: (La suma de ese digito + 7) mod 10 . Luego intercambie el primer dígito por el tercero y
el segundo digito por el cuarto.
Presente el resultado en pantalla.
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 482/499
Universidad de Puerto RicoAdministración de Colegios Regionales
Colegio Universitario Tecnológico de Bayamón
A.C.C(Asociación de Ciencias de Cmputadoras)
21 de febrero de 1998
Competencias: Estudiantes de Nuevo lngreso
Ejercicio #2:
Decodifica el código generado por el primer programa (Ejercicio I).
Su programa debe leer este código entero de cuatro dígitos, descodificarlo y presentado en pantalla.
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 483/499
C+'p$t$n"&*! E!tu,&*nt$! ,$ Nu$)+ In@#$!+
E0$#"&"&+ 3
E( p#+p7!&t+ ,$( p#+@#*'* $! "#$*# un *(@+#&t'+ u$ ($* un '$n!*0$ ,$( *#" &)+-$N0A8$4TOT4
E!t$ '$n!*0$ ,$5$ !$# t#*,u"&,+ * "7,&@+ M+#!$. En p*nt*((* ,$5$ *p*#$"$# $( '$n!*0$ t*( - "+'+ $!t$( *#" &)+ - (u$@+ ,$5$ p#$!$nt*# !u t#*,u""&7n.
C7,&@+ M+#!$
*X .> 0X .>>> #X .>. 5X > ?X >.> !X "X >.>. (X .>.. tX >,X >.. 'X >> uX ..>$X . nX >. )X >X ..>. 9X >>.>> X .>>@X >>. +X >>> X >..>X . PX .>>. -X >.>>&X .. X >>.> 8X >>..
1X .>>>> :X > .2X ..>>> X >>3X >> X >>>..4X .> X >>>>.X .. <X >>>>>
E0$'p(+ ,$ "+##&,*M$n!*0$ J+(*.
S*(&,*J+(*.
.>>>.>...>
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 484/499
Categoría intermedio
PRO+RAMA DECODI*ICACI<N DO#$E
E1 programa anteriormente mencionado consiste en una doble decodificación de datos Estructurada en la sigumanera la letra A debe ser reeplasada por el espacio en blanco la letra B debe ser suplantada por la letra Z ymismo consecuentemente Por todo el abecedario. Despues de haber concluido con la inversión la salida del progrdebe dar su valor numerico en respecto a la posición de el dato dentro del abecedario (el espacio en blanco despues de la letra Z.
Ejemplo:
A B C D E F G H I J K L M N O P Q R S T U V W X Y Z -
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 2
E1 (-) = Espacio en blanco
Entrada= t o m aCodifucación nivel 1 =Codifucación nivel 2 = 14 17 21 27
La decodificación del mismo debe ser entrada en números y el resultado debe ser la entrada original en el ejercicianteriormente mencionado el mismo debe ir a el archivo encry.dat
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 485/499
Intermedio
Crear un programa que simule la registración de entrada y salida de un hospital. E1 Hospital solo acepta10 pacientes. E1 proceso de registración debe de estar siempre online hasta que el comando shutdown seaseleccionado en el menú. Los pacientes de alta se sacan de la lista activa y se colocan en una lista pasiva.E1 programa debe aceptar el nombre del paciente, el número de seguro social, dia y hora que entró y elcuarto donde se va a colocar. En el hospital hay solo 5 habitaciones de la habitación 101 a la 105. El
programa debe tener un menú para manejar la registración. E1 menú debe tener las opciones de aceptar unpaciente, dar de alta, cambiar a un paciente de cuarto y reportes. En reportes debe haber otro menú con lasopciones de imprimir la información en pantalla de un paciente buscada por seguro social, la opción decuartos para ver la capacidad disponible y la opción de pacientes dados de alta.
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 486/499
Fecha llllbllllbllll Nombre de la competencia llllllllllllllll Categoría B$@&nn$#! Universidad( CUBYYYYY lllllllllllllAutor lllllllllllll Tipo de competencia E(&'&n*t+#&*Problema lllll Algoritmos lllllllllllllllllllllllll
C#$*# un p#+@#*'* u$ t#*n! +#'$ un !t#&n@!t#&n@ ut&(&8*n,+ (* "*nt&,*, '$n+# ,$ $,&"&+n$$,&"&+n$! !$ *"$n "+n (+! "+'*n,+! ,$ D$($t$ p*#* 5R&@ t p*#* '+)$#!$ * (* ,$#$" * $ In!$#t p*#* "+(+"*# ,*t
E( p#+@#*'* ,$5$ &n,&"*# "u*nt*! $,&"&(($)*#*n *"*5+. E( p#+@#*'* ,$5$ !$@u&# p&,&$n,+!t#&n@ *!t* u$ un+ ,&@* (+ "+nt#*#&+.
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 487/499
5ig Sc ool C allenge B FP*@$. 1
Problem &(
An JTML L&n? G$n$#*t+# &! * p#+@#*' t *t #$"$&)$! *n Input &($ PROBI.IN % t *t +#u($! *n, @$n$#*t$! *n +utput &($ PROEI.+u# *""+#,&n@(-. M*?$ *n FITML L&n? "#$*t$! *n +utput &t$ +((+ &n@ t $!$ #u($!
Q In? ( ! n*'$0aQIIn? ( ! *,,'!!(Q In? 2 ! n*'$0aQ1In? 2 ! *,,'!!0
T $ +utput &($ PROE( .+u# ! +u(, 5$ *! +((+ !(
fL&Z fA JREFX ((In? &• S *,,'!! TMZ (&n? &6! n*'$A fL&Z FIREFX @&n? T! *,,'!! Z (&n? T! n*'$ fIAZ
T $ p#+@'' ! +u(, +#? n+ '*tt$# *t t $ n*'$! + t $ (&n?! *'6 *t t $ *,,#$!!$! + t $!$(&n?! *#$6 +# + '*n- (&n?! t $' *#$ &n t $ &($.
F+# t $ Input &($6 PROB1.IN\
Y* ++ ! JPa ttp bb .-* ++."+'T$!t P*@$a ttp bb'-!&t$.'-n+,$.+#@
t $ +utput &($6 PROB1. uT6 ! +u(, 5$
fUL.ZfLIZ fA JREFX ttp bb .-* ++."+' Z Y* ++ ! JP fbAZfLIZ fA JREEX ttp bb'-!&t$.'-n+,$.+#@ Z T$!t P*@$ fbAZ fbULZ
J&@ S" ++( C *(($n@$ 1P*@$ 2
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 488/499
Problem '(
M*?$ * p#+@#*'' t *t +utput! t $ "+'put$# "(+"?d! t&'$6 !&'u(*t&n@ t $ " *#*"t$#! #+' * "(+"?.
E 'p($I t $ "+'put$#d! t&'$ up+n $ $"ut&+n &! 21 AM6 t $ p#+@'' ! +u(, +utput
21 AI t $ +u# $($ PM6 In!t$*, O *n A6 * P ! +u(, 5$ #&tt$n * t$# t $ t&'$.
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 489/499
J&@ S" ++( C *(($n@$ 1P*@$ 3
Problem =(
M*?$ * p#+@#*' t *t #$*,! *n $n"+,$, &($ npRO:3.INI.%6 ,$"+,$! It6 *n, #&t$! t $ ,$"+,$, ,*
+utput &($ PROB3.OUT\%. T $ "+,(&"*t(+n &(( 5$ @&)$n 5- t $ +((+ &n@ !" $'$
ABCDEFGJIH LMNOP RSTUVK;YY;KVUTSR PONMLICIIJGFEDCBA
t *t &!6 A "+,& &$! t+ > *n, )&"$>)$#!*6 U "+,& &' t+ n+n *n, )I"$>)$#!*6 *n,[ N\ "+,& &$! 5$(t A(( " *'"t$#! t *t *' n+t ($tt$#! &(( 5$ "+p&$, un" *n@$, t+ t $ +utput &($6 5ut (+ $#"*!$ ($ 5$ ,$"+,$, t+ t $&# "+##$!p+n,&n@ ($tt$# n( $n In upp$#"*!$%6 !+ t *t *n # +u(, "+,& - t+
TM +u(, "+,& - t+ *n A In t $ +utput &($.In -+u# I'p($'$nt*tI+n6 YOU MAY NOT USE ARRAYS FOR DECODING. Y+u *)$ t+ ,$!&*(@+#&t ' t+ "*n- +ut t $ ,$"+,&n@ p#+"$!!6 5ut -+u '*- NOT u!$ *#'-n t *t "+nt*&n "+n)$#!&+T $ p#+@'' ! +u(, +#t +# ANY t$ t "+nt*&n$, In PROB3.IN6 Y 5ut t $ t$!t &($ t *t -+u *)$ 5$$@&)$n I! t $ +((+ &n@
A5CDEFG IH IMNOp RStUVK;- IH
A t$# $ $"ut&+n6 t $ +utput &#$6 PROBS.OUT6 ! +u(, "+nt*&n t $ +((+ &n@
Y;KVUTSR PONML HIJGFEDCBA1lW
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 490/499
J&@ S" ++( C *(($n@$ 1 P*@$ 4
Problem +(
M*?$ * p#+@'' t *t *!?! t $ u!$# +# t $ $($'$nt! Int$@$# nu'5$#!% + * ! u*#$ '*t#& "+nt*&#+ ! *n, 3 "+(u'n!6 *n, "*("u(*t$! *n, p#Int! +ut t $ ,$t$#'&n*nt + !*&, '*t#& . E *'p($ + + "*("u(*t$ t $ ,$t$#'In*nt + * 3 3 '*t#&
Q1 2 3Q4 >:Q
D$tX1 Q > :% >2 4 > :% 3 Q4 . %X > 2
T *t &!6 +n$ t*?$! t $ &#!t nu'5$# + t $ &#!t #+ In t &! "*!$6 * 1% *n, +n$ 'u(t(p(&$! &t p#+,u"t + (&$ +u# nu'5$#! t *t *' NOT "+nt*&n$, &n t $ !*'$ #+ *n, "+(u'n *! t $ 1. In t &! t $!$ +u# nu'5$' *' 6 >:6 *n, . T $n6 +n$ 'u(t&p(&$! t $ &#!t nu'5$# &t t $ t &#, %6 *t $n SUBSTRACTS t $ p#+,u"t + t $ +u#t nu'5$# *n, t $ !$"+n, >:%. T $n6 +n$ SUBSTRAt $ !$"+n, nu'5$# +n t $ &#!t #+ &n t &! "*!$6 2% 'u(t&p(&$, 5- t $ "#+!!>p#+,u"t + t $ nu'5$#n+t &n t $ !*'$ #+ *n, "+(u'n *! t $ 26 *n, &n*((-6 +n$ ADDS t $ t &#, )*(u$ +n t $ &#!t #+ 'u(t&p(&$, 5- t $ "+##$!p+n,&n@ "#+!!>p#+,u"t
.nput
Ent$# t $ )*(u$! +# R+ 1 > 2 <Ent$# t $ )*(u$! +# R+ 2 :Ent$# t $ )*(u$! +# R+ 3 41
:utput
T $ ,$t$#'&n*nt + t $ '*t#& &!. 234
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 491/499
J&@ S" ++( " *(#+n@$ 1 P*@$!
Problem (
M*?$ * p#+@#*' t *t !p(&t! t $ &($ !p$"& &$, 5- t $ u!$# +n t $ "+''*n, (&n$ &nt+ !'*$#$ t $ !&8$ + t $!$ &($! &! *(!+ !p$"& &$, +n t $ "+''*n, (&n$. E *'p($
C b p#+5 p#+5 .&n 4
&(( 5#$*? t $ &($ "*(($, [p#+5 .&n\ &n !'*(($# &($! + 4 " *#*"t$#! $*" . T $!$ &($! &(( 5$ "[p<<1 6 $t"$t$#*6 t *t &!6 t $ &#!t ($tt$# + t $ &($ !p$"& &$, +((+ $, 5- t #$$ nu'5$#!6 &" <<< t+ & n$"$!!*#-%. I t $ &($ ,+$! n+t $ &!t6 *n $##+# '$!!*@$ ! +u(, 5$ @&)$n.
T $ p#+@#*' ! +u(, +#? +# *n- &($ t *t &! !p$"& &$, +n t $ "+''*n, (&n$6 5ut & t $ t$!t
[p#+5 .&n
E!t* $! un* p#u$5*
&! 5#+?$n In &($! : " *#*"t$#! (+n@ $*" 6 t $!$ +u(, 5$
p<<<
E!t* $
p<<1
! un*
p<<2
p#u$5*
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 492/499
p#+@#*'* p#+@1.*#" &)+ ,$ $nt#*,* p#+@1.&n*#" &)+ ,$ !*(&,* p#+@1.+ut
Problema XB: Re"!a de NWmero" +rande"
E!"#&5* un p#+@#*'* u$ #$!t$ ,+! n/'$#+! ,$ *!t* 32 "& #*! ,$ (*#@+.
A!u'*
1. L+! ,+! n/'$#+! !$ $n"u$nt#*n $n un* '&!'* (`n$* !$p*#*,+! p+# un $!p*"&+.2. A'5+! n/'$#+! !+n $nt$#+! p+!&t&)+! *un u$ (* ,& $#$n"&* n+ t&$n$ u$ !$# p+!&t&)*.
,*t* ,$ $0$'p(+
4<< 3211<<< 2<<1
!*(&,*
4<< > 321 X 1<<< = 2<<1 X >1<<1
$liminatoria CUTB V+
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 493/499
p#+@#*'* p#+@2.
*#" &)+ ,$ $nt#*,* p#+@2.&n
*#" &)+ ,$ !*(&,* p#+@2.+ut
Problema X4: Camino del Caballo
En A0$,#$8 J$ *@+n*(6 $( p*!+
,$( "*5*((+ !$ ,$ &n$ "+'+
'u$!t#* $( ,&*@#*'*. L*! 12
$ u&! 'u$!t#*n (+! ,+"$
p+!&5($! p*!+! ,$ $!t$ ,$!,$ (*
"*!&((* @:.
P#+5($'* E!"#&5* un p#+@#*'*
u$ "*("u($ $( "*'&n+ u$ $(
"*5*((+ ,$5$ t+'*# ,$!,$ un
$ _@+n+ &n&"&*( * +t#+.
$liminatoria CUTB V+
g e
c(b(
c&
dF
"
e(
;
f2
f"
f&
f$
f(
;
1
g(
g)
h(
(
f' i
k
B
4
2
BB
8 F
B
Q
BB B
F 8
Q
2
4
B
a b
c d
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 494/499
A!u'*
1. L*! p+!&"&+n$! ,$(
t*5($#+ !$ $!"#&5$n nd ,+n,$
d $! (* ($t#* ,$ (* "+(u'n*6 -
nd $! $( nu'$#+ ,$ (`n$*.
2. C*,* (`n$* ,$( *#" &)+ ,$
f
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 495/499
$nt#*,* $!t* $n $( +#'*t+ >-- ,+n,$ $! (* p+!&"&7n ,$ *##*n u$ ,$( "*5*((+6 - (*&n*(. T+,*! (*! p+!&"&+n$! $n $!t$ *#" &)+ !$ $n"u$nt#*n $n $( t*5($#+.
D*t* ,$ $0$'p(+ 03>"
!*(&,*
Un camino desde %= hasta c es %=>%,>h+>7 >c
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 496/499
(:
% pies
plataformas!
trompa!
piedra!
entrada cueva! 9
p#+@#*'* p#+@3.*#" &)+ ,$ $nt#*,* p#+@3.&n*#" &)+ ,$ !*(&,* p#+@3.+ut
Problema #3 : 2l elefante Furioso
Un $($ *nt$ $!t* 'u- u#&+!+ p+# u$ un*! #*t*! *n"+n!t#u&,+ un* "u$)* $n $( +n,+ ,$ !u p+8+ ,$ *@u*#$!"*. P+# (+ u$ $!t* * ,$"&,&,+ '$t$# (* t#+'p* $n$( *@u* - t*p*# (* $nt#*,* ,$ (* "u$)* "+n un* ,$ (*! p&$,#*! u$ !$ $n"u$nt#*n $n $( _#$*.D$!* +#tun*,*'$nt$6 $( $($ *nt$ !$ $n"+nt#7 "+n ,+! p#+5($'*! p#&'$#+6"+'+ $( p+8+ $! 'u- p#+ un,+ n+*("*n8* (* $nt#*,*6 p+# (+ u$ t$n,#_ u$ !+(t*# (* p&$,#*6 - !$@un,+6 u$ n+ (* pu$,$ !+(t*# ,&#$"t*'$nt$6 p+# u$ (*! #*t*!6 "*n!*,*! ,$ t*nt+ 5u"$*#6 *n "+n!t#u&,+ *,$'_! un*! p(*t* +#'*! &n"(&n*,*! $n (*! u$ *"$n $!"*(* *( $nt#*# - !*(&# ,$( *@u*.
Cuando el ele7ante suelta la piedraJ esta acumula velocidadJ y rebota cuando choca con unade las plata7ormas4 /erdaderamenteJ cada veQ Gue la piedra caeJ esta acumula velocidad4Por otro ladoJ la piedra la pierde cuando sube o cuando se mueve para la iQGuierda o laderecha4 :bserve el siguiente e%emplo(
!a piedra cae ' J choca con la plata7ormaJ se desplaQa ' a la derechaJ y cuando pierde
toda la velocidadJ vuelve a caer4
!as piedras pueden chocar con las plata7ormas por encima o por deba%o4 $l e7ecto es
siempre el mismo( la piedra puede subir o moverse para los lados la misma cantidad
de pies Gue ba%a4
$liminatoria CUTB V+
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 497/499
Problema( #ado Gue el ele7ante puede hundir la trompa en cualGuier parte del poQo unos +piesJ determine de donde debe soltar la piedra para Gue esta tape la entrada del la cueva4
Asumir(
$l poQo mide pies de ancho y pies de pro7undidad4
$l ele7ante puede mover el ultimo pies de la trompaJ por lo Gue puedeJ dado Gue
no se encuentre ninguna plata7orma en el caminoJ hundir la trompa = pies y . para la
iQGuierda o la derecha4
$l archivo contiene un mapa del poQoJ donde los puntos 246 llenan los espacios de aguaJ
las plata7ormas se representan con X o < J dependiendo de la dirección de estaJ y la
entrada de la cueva se marca con una 54 !a entrada de la cueva siempre esta en el 7ondo4
0i la piedra pierde todo velocidadJ y se encuentra posada sobre el piso o una plata7ormaJ
no se mueve de ahí4
0i la piedra choca contra una de las paredesJ esta rebota en la dirección contraria4
0e garantiQa Gue el mapa tiene solución4
$l girar la trompa se debe especi7icar como a la iQGuierdaJ derechaJ o no es necesario4
data de e%emplo(
4 4 4 4 4 4 4 4
4 4 4 4 4 4 4 4
4 4 4 4 4 4 4 4
4 4 4 4 4 4 X 4
4 4 4 X 4 4 4 4
4 4 4 4 4 < 4 4
4 4 4 5 4 4 4 4salida(
distancia del borde(
pro7undidad( +
girar( no es necesario4
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 498/499
Fecha Nombre de la competenciaCategoría UniversidadAutor Tipo de competenciaProblema Algoritmos
N:TA 9$N$RA!( !A /A!.#AC.:N #$#AT:0 $0 R$EU$0.T: $N T:#:0 !:0
PR:B!$-A04
PROBLEMA #1
E!"#&5* un p#+@#*'* u$ #$*(&8$ un* !$#&$ ,$ "+n)$#!&+n$! ,$ G#*,+! F*#$n $G#*,+! C$("&u!. E( '&!'+ ,$5$ p$,&# ,$( u!u*#&+ $( p#&'$# )*(+# ,$ (* !$#&$6 - (* $!"$n (* u$ !$ ,$!$* u$ *u'$nt$ (* $!"*(*. A,$'_!6 $( u!u*#&+ t*'5& n $nt#*#_ $( n/'$#+,$ )$"$! u$ ,$!$* u$ !$ *@* (* "+n)$#!&7n. N+t* (* $"u*"&7n ,$ "+n)$#!&7n $! (* !&@u&$nt$ F*#$n $&t = 32%b1.
E0$'p(+ ,$ C+##&,*
Ent#$ $( p#&'$# )*(+# ,$ (* !$#&$ <Ent#$ (* $!"*(* $n u$ ,$!$* u$ *u'$nt$ (* !$#&$ 4Ent#$ $( n/'$#+ ,$ "+n)$#!&+n$! u$ ,$!$* #$*(&8*# 3G#*,+! F*#$n $&t G#*,+! C$("&u!
< 1<4 12.22
14.44
PROBLEMA #2
E!"#&5* un p#+@#*'* u$ ($$#_ ,$( u!u*#&+ un "*#*"t$#6 - (u$@+6 ,&#_ !& $( "*#M*-/!"u(* + M&n/!"u(*a - (+ &'p#&'&#_ $n p*nt*((*6 0u!t+ $n (* p+!&"&7n ,$( *( *5$t+($ "+##$!p+n,$. L+! $!p*"&+! *nt$!6 - ,$!pu ! ,$( "*#*"t$#6 ,$5$n $!t*# + up*,+! p+# > . N+t* S$ ut&(&8*#_ $( *( *5$t+ *'$#&"*n+.
E0$'p(+ ,$ "+##&,*
Ent#$ un "*#*"t$# ,
E( "*#*"t$# $! '&n/!"u(*.>>>,>>>>>>>>>>>>>>>>>>>>>>>
8/13/2019 Competencias Program Ac i on Inter Colegiales
http://slidepdf.com/reader/full/competencias-program-ac-i-on-inter-colegiales 499/499
PROBLEMA 3
E!"#&5* un p#+@#*'* u$ p&,* ,$( u!u*#&+ un n+'5#$ ,$ un $'p($*,+6 - un t+t*( ,$ +#*!t#*5*0*,*! - ,*,* $!t* &n +#'*"&7n *@* (+! "*("u(+! "+##$!p+n,&$nt$! $ &'p#&'* (*!&@u&$nt$ &n +#'*"&7n
a6 N+'5#$ ,$( $'p($*,+b6 E( !*(*#&+ 5#ut+ ,$( $'p($*,+c6 L* "*nt&,*, * ,$!"+nt*# p+# "+n"$pt+ ,$ &'pu$!t+!d6 L* "*nt&,*, * @*n*# p+# "+n"$pt+ ,$ +#*! $ t#*!e6 L* "*nt&,*, * ,$!"+nt*# p+# "+n"$pt+ ,$ p(*n ' ,&"+76 t+t*( ,$ ,$,u""&+n$!g6 S*(*#&+ n$t+
4ota: Pa&a por %ora, %asta 8 %oras: @6. C*,* +#* p+# $n"&'* ,$ 4< +#*! ^ . <I'p $!t+ $( !*(*#&+ 5# t+ S& $( !*(*#&+ 5# t+ $! '* +# $ ^3<<6 $(