Universidad
de Puerto Rico
Administración
de Colegios Regionales
Colegio
Universitario Tecnológico de Bayamón
PROBLEMAS PARA ELIMINATORIAS
CATEGORIA: INTERMEDIOS
Escriba un programa que solicite al usuario una palabra de
5 letras. Luego tiene que tirar por
pantalla todas las posibles combinaciones (permutaciones) de esa palabra. El programa tiene que validar la entrada de
datos de modo que solo permita aceptar letras y el largo tiene que ser igual a
cinco. (Ver anexo.)
Escriba un programa que solicite al usuario el número máximo de una lista. Luego procede a tirar por pantalla comenzando en uno hasta el número dado, las siguientes representaciones:
Decimal, Octal, Hexadecimal y
Binario.
Ejemplo:
Entre un número (no mayor de 200): 8
Decimal Octal Hexadecimal Binario
1 1 1 1
2 2 2 10
3 3 3 11
4 4 4 100
5 5 5 101
6 6 6 110
7 7 7 111
8 10 8 1000
EL programa debe validar la entrada de datos y cuando la pantalla se llene, debe pausar para que el usuario pueda ver los datos e indicar cuando desea continuar.
Fecha: 15/05/2000 Nombre de la competencia: _________
Categoría: Intermedia Division Universidad: CUB DE PUERTO RICO
Autor: Nelson Rivera Tipo de competencia:_______________
Problema #: 1 Algoritmos: _______________________
INTERMEDIA
DIVISION
Problem1. STACK MANIPULATION
Source File Nam ID1.XXX
Write a program that converts an expression in infix notation to postfix and prefix notation. Your program should write as output the original expression in infix notation, the expression in postfix and in prefix notation. Each expression should be in a separate line, and properly labeled.
Sample Input:
(2+4/9)*3
Sample Output:
infix notation: (2+4/9)*3
postfix notation: 24 9+3*
prefix notation: +/24 9*3
Fecha: 15/05/2000 Nombre de la competencia: _________
Categoría: Intermedia Division Universidad: CUB DE PUERTO RICO
Autor: Tipo de competencia:_______________
Problema #: 2 Algoritmos: _______________________
Problem 2. EASY CALENDAR
Source File Name: ID2.XXX
Input File Name: ID2.DAT
Output File Name: ID2.OUT
Write a program that takes as input a date with the format:
mmmddyyyy
(yyyy can be any year before or after 1993)
and returns the day of the week corresponding to that date (i.e.,
Monday, Tuesday, etc.). Your
program should also test for any invalid input, e.g. feb 29 1993 and report an
error message in that case.
Remarks:
A given year is defined as a “leap” year if the year is divisible by
400, or if it is divisible by 4 but not by 100. For example, the year 2000 is a
leap year; 1900 is not a leap year.
Sample Input:
feb 02 1993
Sample Output:
feb 02 1993 is a Tuesday
Fecha: 3/05/1997 Nombre de la competencia:CUTB Programming Contest Categoría: Intermedia Division Universidad: CUB DE PUERTO RICO
Autor: Tipo de competencia:_______________
Problema #: 3 Algoritmos: _______________________
INTERMEDIATE
DIVISION
EIGHT QUEENS WITH A TWIST
Problem 3:
Eight queens can be arranged on a chess board so that no Queen is under attack from any of the others; in other words, so that no row or column or diagonal contains more than one queen. Write a program that will place the position of 8 queens on a chess board and ensures that no Queens are under attack. Your program should first draw the chess board displaying the X Y matrix with Q’s representing the Queen position. The program must also search and display all the solutions for this problem. The answers should show the correct solution.
Note: No hard-wired solution are allowed!
Sample
Output:
1 2 3 4 5 6 7 8
1 Q
2 Q
3 Q
4 Q
5 Q
6 Q
7 Q
8 Q
PRESS
ENTER FOR NEXT SOLUTION>
Categoria: INTERMEDIO CUB
Programming Contest
Problem
set
Author: USACO May
29,1999
Super Roman Numerals [Kolstad, 1997]
You've heard the story of Romans like Midas who had the `Golden Touch'.Midas was no fool and sold his gold for lots of money. The traditional Roman numerals proved inconvenient for expressing the value of his fortune, whichranged into the millions. He invented Super Roman Numerals.
Super Roman Numerals follow the traditional rules for
Roman numerals but have many more single-character values. Consider the traditional Roman numeral
values, shown here with the single letter and the decimal number it represents:
I 1 L 50 M 1000
V 5 C 100
X 10 D 500
As many as three of the same marks that represent 10^n may be placed consecutively:
III is 3
CCC is 300
Marks that are 5 * 10^n are never used consecutively. Generally (with the exception of the next rule), marks are connected together and written in descending order:
CCLXIII = 100+100+50+10+1+1+1 = 263
Sometimes, a mark
that represents 10^n is placed before a mark of one of the two next higher
values (I before V or X; X before L or C; etc.). In this case, the
value of the smaller mark is SUBTRACTED from the mark it precedes:
IV = 4
IX = 9
XL= 40
But compound marks like XD,
IC, and XM are not legal, since the smaller mark is too much smaller than
the larger one. For XD (wrong for 490), one would use CDXC; for IC (wrong for 99), one would
use XCIX; for XM (wrong for 990), one would use CMXC.
Regrettably, in standard Roman numerals, numbers like 10,000
are represented as MMMMMMMMMM. In Super Roman Numerals, the table of marks
is extended:
I 1 L 50 M 1,000 R 50,000 U 1,000,000 N 50,000,000
V 5 C 100 P 5,000 S 100,000 B 5,000,000 Y 100,000,000
Numbers
greater than 100 million are now easily expressible. Write a program that reads non-negative decimal numbers (one per
line) from the file INPUT.DAT and
prints the Super Roman Numeral equivalent.
It is promised that the input data will require an answer that is
representable using the given rules.
Stop your program when the input number is a 0.
SOLUCIONES
Super Roman Numerals [Kolstad, 1997]
SAMPLE INPUT (file INPUT.DAT):
18
1997
12345678
0
SAMPLE OUTPUT:
18 XVIII
1997 MCMXCVII
12345678 WUUSSSQRPDCLXXVIII
TEST DATA SET #1:
18
1998
87654321
99999999
11111
-