Professional Documents
Culture Documents
Practica 1
Practica 1
Sample Output
I evol .uoy
uoY evol .em
er'eW a yppah .ylimaf
ACM Contest Problems Archive University of Valladolid (SPAIN)
Input
The input consists of several data sets. Each set begins with a line containing the number n of stacks
Bob has built. The next line contains n numbers, the heights h of the n stacks. You may assume
i
1 n 50 and 1 h 100.
i
The total number of bricks will be divisible by the number of stacks. Thus, it is always possible to
rearrange the bricks such that all stacks have the same height.
The input is terminated by a set starting with n = 0. This set should not be processed.
Output
For each set, rst print the number of the set, as shown in the sample output. Then print the line \The
minimum number of moves is k .", where k is the minimum number of bricks that have to be moved
in order to make all the stacks the same height.
Output a blank line after each set.
Sample Input
6
5 2 4 1 7 5
0
Sample Output
Set #1
The minimum number of moves is 5.
UNIVERSIDAD NACIONAL DE INGENIERÍA
Facultad de Ciencias / Ciencia de la Computación
Práctica de Laboratorio 02
Introducción a la Programación (VIE 10:00-12:00h) CC102 - A1
Cada solución debe incluir la explicación de la estrategia a usar y el programa en “C” Duración: 1h 30min
El siguiente bloque de código, estructura la solución, −−− −−− −−− −−− −−−
usted debe escribir el cuerpo de la función cuen- | | | | | | | |
ta palabras: | | | | | | | |
| | | | | | | |
#include <stdio.h> −−− −−− −−−
int cuenta palabras(char cad[]); | | | | | | | |
int main(){ | | | | | | | |
char cadena[1000]; | | | | | | | |
int n; −−− −−− −−− −−−
while(gets(cadena)){
n=cuenta palabras(cadena);
printf (” %d\n”,n);
}
4. (4 puntos) Peter’s Smokes/uva:10346
Peter es un fumador economizador, el tiene n cigarros y
return 0;
ha hallado la forma de armar un nuevo cigarro con k co-
}
the
street 5. (4 puntos) 500! /uva:623
El factorial de 500 posee 1135 digitos. Se trata de escribir
Se retornaria: un programa que retorne el factorial de cualquier numero
menor que 1000. Por ejemplo para el caso:
nw
et 10
30
3. (4 puntos) LC-Display/uva:706 Deberá retornar:
Se debe construir un numeral N, basado en a segmentos.
Se ingresan muchas lineas, un caso por linea, en cada li- 10!
nea se ingresa el valor de N, seguido de a. 3628800
Una linea con 0 0 indica el final de la entrada. Por ejem- 30!
plo para el caso: 265252859812191058636308480000000