ACM Octubre 2014

download ACM Octubre 2014

of 9

Transcript of ACM Octubre 2014

  • 8/10/2019 ACM Octubre 2014

    1/9

    !"#$%&' )#*+',*,-' .$ /%'0%,1,*#'-

    a) Displays

    Basename: DisplaysDescription

    A seven segment display, similar to the one shown on the right, iscomposed of seven light-emitting elements. Individually on or off, theycan be combined to produce 127 different combinations, including theten Arabic numerals. The figure on the next page illustrates how theten numerals are displayed. 7-seg displays (as theyre oftenabbreviated) are widely used in digital clocks, electronic meters, andcalculators. A 7-seg has seven connectors, one for each element, (plusfew more connectors for other electrical purposes.) Each element canbe turned on by sending an electric current through its pin. Each of theseven pins is viewed by programmers as a single bit in a 7-bit number,as they are more comfortable dealing with bits rather than electrical

    signals. The figure on the right shows the bit assignment for a typical 7-seg, bit 0 being the right-most bit. For example, in order to display thedigit 1, the programmer knows that only bits 1 and 3 need to be on, i.e.the 7-bit binary number to display digit 1 is 0001010, or 10 in decimal.Lets call the decimal number for displaying adigit, its display code, or

    just code for short. Since a 7-seg displays 127 different configurations,display codes are normally written using 3 decimal places with leadingzeros if necessary, i.e. the display code for digit 1 is written as 010.In a 9-digit calculator, 9 7-seg displays are stacked next to each other,and are all controlled by a single controller. The controller is sent asequence of 3n digits, representing n display codes, where 0 < n < 10.If n < 9, the number is right justified and leading zeros are

    automatically displayed. For example, the display code for 13 is010079 while for 144 it is 010106106Write a program that reads the display codes of two numbers, andprints the display code of their sum.

    !"#$% '()*+%

    Your program will be tested on one or more test cases. Each test case isspecified on a single line in the form of A+B= where both A and B are displaycodes for decimal numbers a and b respectively where 0 < a,b < a + b < 1, 000,000, 000.The last line of the input file is the word "BYE" (without the double

    quotes.)

    ,$%#$% '()*+%

    For each test case, print A+B=C where C is the display code for a + b.

    -+*#./ !"#$%0,$%#$%

    !"#$% ,$%#$%

    010079010+010079=106010+010=

    010079010+010079=010106106106010+010=106093

  • 8/10/2019 ACM Octubre 2014

    2/9

    !"#$%&' )#*+',*,-' .$ /%'0%,1,*#'-

    BYE

  • 8/10/2019 ACM Octubre 2014

    3/9

  • 8/10/2019 ACM Octubre 2014

    4/9

    !"#$%&' )#*+',*,-' .$ /%'0%,1,*#'-

    followed by a single space, followed by the total number of points the team has scoredduring the season. The teams standing should be followed by a blank line.-+*#./ !"#$%0,$%#$%

    !"#$%

    ,$%#$%

  • 8/10/2019 ACM Octubre 2014

    5/9

  • 8/10/2019 ACM Octubre 2014

    6/9

    !"#$%&' )#*+',*,-' .$ /%'0%,1,*#'-

    72 895": + "$*1/)

    Basename: 895":Description

    Number guessing is a popular game between elementary-school kids. Teachersencourage pupils to play the game as it enhances their arithmetic skills, logical thinking,and following-up simple procedures. We think that, most probably, you too will master infew minutes. Heres oneexample of how you too can play this game: Ask a friend to thinkof a number, lets call it n0.Then:

    1. Ask your friend to compute n1 = 3 $ n0and to tell you if n1is even or odd.

    2. If n1is even, ask your friend to compute n2 = n1/2. If, otherwise, n1was odd thenlet your friend compute n2= (n1+ 1)/2.

    3. Now ask your friend to calculate n3= 3 $ n2.

    4. Ask your friend to tell tell you the result of n4= n3/9. (n4is the quotient of thedivision operation. In computer lingo, / is the integer-division operator.)

    5. Now you can simply reveal the original number by calculating n0= 2 $ n4if n1was

    even, or n0= 2 $ n4+ 1 otherwise.

    Heres an example that you can follow: If n0= 37, then n1= 111 which is odd. Now we cancalculate n2= 56, n3= 168, and n4= 18, which is what your friend will tell you. Doing the

    calculation 2 n4+ 1 = 37 reveals n0.

    !"#$% '()*+%

    Your program will be tested on one or more test cases. Each test case is made of a singlepositive number (0 < n0< 1, 000, 000).The last line of the input file has a single zero (which is not part of the test cases.)

    ,$%#$% '()*+%

    For each test case, print the following line:

    k.BQWhere k is the test case number (starting at one,) B is either even or odd (without thequotes) depending on your friends answer in step 1. Q is your friends answer to step 4.

    -+*#./ !"#$%0,$%#$%

    !"#$% ,$%#$%

    37380

    1. odd 182. even 19

  • 8/10/2019 ACM Octubre 2014

    7/9

    !"#$%&' )#*+',*,-' .$ /%'0%,1,*#'-

    /2 ;().7 3$#

  • 8/10/2019 ACM Octubre 2014

    8/9

    !"#$%&' )#*+',*,-' .$ /%'0%,1,*#'-

    >2 ?. @)+" +3()7/A"

    Basename: B3()7/("

    C/=3)5#35A"

    "#$%& '& () *' +&,(' -*. /0122#'3( 4*( 516#-&)7 82 4*1(0( $&-9(310 $&' )* #-16& :#'$%13&7 9#0#

    %#$(02& ,(0 -;) &2,15#51

  • 8/10/2019 ACM Octubre 2014

    9/9

    !"#$%&' )#*+',*,-' .$ /%'0%,1,*#'-

    L( 5(/(0;' 1-901-10 D2@'(#)7 *'# 9&0 $#5# 9#@) 90(6*'3#5& 9&0 "#$%&= L1 (2 9#@) 5( 2# 90(6*'3#

    no est en el acorden, se debe imprimir !" $%&"%'()*". Si el pas preguntado est en el

    #$&05(?'7 5(/(0; imprimir +,$% si la respuesta es correcta, de otra manera debe imprimir

    -)..

    ?E/*#.(= ?"%)+7+0-+.57+

    O'30#5# L#215#

    P Q

    R0#'$1# :#01)

    S(T1$& S(T1$&

    U3#21#

    S(T1$& S(T1$&

    R0#'$1# G&'50()

    "& ('$&'30#5&

    V1('

    S#2