Sie sind auf Seite 1von 188

URI Online Judge | 1001

Extremely Basic
Adapted by Neilor Tonin, URI Brazil
Timelimit: 1

Read 2 integer values and store them in variables, named A and B and make the sum of these two
variables, assigning its result to the variable X. Print X as shown below. Don't present any message
beyond what is being specified and don't forget to print the end of line after the result, otherwise you
will receive Presentation Error.

Input
The input file contain 2 integer values.

Output
Print the variable X according to the following example, with a blank space before and after the equal
signal. 'X' is uppercase and you have to print a blank space before and after the '=' signal.

Input Samples Output Samples

10 X = 19
9
-10 X = -6
4
15 X = 8
-7

URI Online Judge | 1002


Area of a Circle
Adapted by Neilor Tonin, URI Brazil
Timelimit: 1

The formula to calculate the area of a circumference is defined as A = . R2. Considering to this
problem that = 3.14159:

Calculate the area using the formula given in the problem description.

Input
The input contains a value of floating point (double precision), that is the variable R.

Output
Present the message "A=" followed by the value of the variable, as in the example bellow, with four
places after the decimal point. Use all double precision variables. Like all the problems, don't forget to
print the end of line after the result, otherwise you will receive "Presentation Error".

Input Samples Output Samples

2.00 A=12.5664
100.64 A=31819.3103
150.00 A=70685.7750

URI Online Judge | 1003


Simple Sum
Adapted by Neilor Tonin, URI Brazil
Timelimit: 1

Read two integer values, in this case, the variables A and B. After this, calculate the sum between
them and assign it to the variable SOMA. Write the value of this variable.

Input
The input file contains 2 integer numbers.

Output
Print the variable SOMA with all the capital letters, with a blank space before and after the equal
signal followed by the corresponding value to the sum of A and B. Like all the problems, don't forget to
print the end of line, otherwise you will receive "Presentation Error"

Input Samples Output Samples

30 SOMA = 40
10
-30 SOMA = -20
10
0 SOMA = 0
0

URI Online Judge | 1004


Simple Product
Adapted by Neilor Tonin, URI Brazil
Timelimit: 1

Read two integer values. After this, calculate the product between them and store the result in a
variable named PROD. Print the result like the example below. Do not forget to print the end of line
after the result, otherwise you will receive Presentation Error.

Input
The input file contains 2 integer numbers.

Output
Print PROD according to the following example, with a blank space before and after the equal signal.

Input Samples Output Samples

3 PROD = 27
9
-30 PROD = -300
10
0 PROD = 0
9

URI Online Judge | 1005


Average 1
Adapted by Neilor Tonin, URI Brazil
Timelimit: 1

Read two floating points' values of double precision A and B, corresponding to two student's grades.
After this, calculate the student's average, considering that grade A has weight 3.5 and B has weight
7.5. Each grade can be from zero to ten, always with one digit after the decimal point. Dont forget to
print the end of line after the result, otherwise you will receive Presentation Error. Dont forget
the space before and after the equal sign.

Input
The input file contains 2 floating points' values with one digit after the decimal point.

Output
Print MEDIA(average in Portuguese) according to the following example, with 5 digits after the
decimal point and with a blank space before and after the equal signal.

Input Samples Output Samples

5.0 MEDIA = 6.43182


7.1
0.0 MEDIA = 4.84091
7.1
10.0 MEDIA = 10.00000
10.0

URI Online Judge | 1006


Average 2
Adapted by Neilor Tonin, URI Brazil
Timelimit: 1

Read three values (variables A, B and C), which are the three student's grades. Then, calculate the
average, considering that grade A has weight 2, grade B has weight 3 and the grade C has weight 5.
Consider that each grade can go from 0 to 10.0, always with one decimal place.

Input
The input file contains 3 values of floating points with one digit after the decimal point.

Output
Print MEDIA(average in Portuguese) according to the following example, with a blank space before
and after the equal signal.

Input Samples Output Samples

5.0 MEDIA = 6.3


6.0
7.0
5.0 MEDIA = 9.0
10.0
10.0
10.0 MEDIA = 7.5
10.0
5.0

URI Online Judge | 1007


Difference
Adapted by Neilor Tonin, URI Brazil
Timelimit: 1

Read four integer values named A, B, C and D. Calculate and print the difference of product A and B
by the product of C and D (A * B - C * D).

Input
The input file contains 4 integer values.

Output
Print DIFERENCA (DIFFERENCE in Portuguese) with all the capital letters, according to the following
example, with a blank space before and after the equal signal.

Input Samples Output Samples

5 DIFERENCA = -26
6
7
8
0 DIFERENCA = -56
0
7
8
5 DIFERENCA = 86
6
-7
8

URI Online Judge | 1008


Salary
Adapted by Neilor Tonin, URI Brazil

Timelimit: 1

Write a program that reads an employee's number, his/her worked hours number in a month and the
amount he received per hour. Print the employee's number and salary that he/she will receive at end
of the month, with two decimal places.

Dont forget to print the line's end after the result, otherwise you will receive Presentation
Error.

Dont forget the space before and after the equal signal and after the U$.

Input

The input file contains 2 integer numbers and 1 value of floating point, representing the number,
worked hours amount and the amount the employee receives per worked hour.

Output

Print the number and the employee's salary, according to the given example, with a blank space
before and after the equal signal.

Input Samples Output Samples

25 NUMBER = 25
100 SALARY = U$ 550.00
5.50

1 NUMBER = 1
200 SALARY = U$ 4100.00
20.50

6 NUMBER = 6
145 SALARY = U$ 2254.75
15.55
URI Online Judge | 1009

Salary with Bonus


Adapted by Neilor Tonin, URI Brazil

Timelimit: 1

Make a program that reads a seller's name, his/her fixed salary and the sale's total made by
himself/herself in the month (in money). Considering that this seller receives 15% over all products
sold, write the final salary (total) of this seller at the end of the month , with two decimal places.

- Dont forget to print the line's end after the result, otherwise you will receive Presentation Error.

- Dont forget the blank spaces.

Input

The input file contains a text (employee's first name), and two double precision values, that are the
seller's salary and the total value sold by him/her.

Output

Print the seller's total salary, according to the given example.

Input Samples Output Samples

JOAO TOTAL = R$ 684.54


500.00
1230.30

PEDRO TOTAL = R$ 700.00


700.00
0.00
MANGOJATA TOTAL = R$ 1884.58
1700.00
1230.50

URI Online Judge | 1010

Simple Calculate
Adapted by Neilor Tonin, URI Brazil

Timelimit: 1

In this problem, the task is to read a code of a product 1, the number of units of product 1, the price for
one unit of product 1, the code of a product 2, the number of units of product 2 and the price for one
unit of product 2. After this, calculate and show the amount to be paid.

Input

The input file contains two lines of data.\ In each line there will be 3 values: two integers and a floating
value with 2 digits after the decimal point.

Output

The output file must be a message like the following example where "Valor a pagar" means Value to
Pay. Remember the space after ":" and after "$" symbol. The value must be presented with 2 digits
after the point.

Input Samples Output Samples

12 1 5.30 VALOR A PAGAR: R$ 15.50


Input Samples Output Samples

16 2 5.10

13 2 15.30 VALOR A PAGAR: R$ 51.40


161 4 5.20

1 1 15.10 VALOR A PAGAR: R$ 30.20


2 1 15.10

URI Online Judge | 1011

Sphere
Adapted by Neilor Tonin, URI Brazil

Timelimit: 1

Make a program that calculates and shows the volume of a sphere being provided the value of its
radius (R) . The formula to calculate the volume is: (4/3) * pi * R 3. Consider (assign) for pi the value
3.14159.

Tip: Use (4/3.0) or (4.0/3) in your formula, because some languages (including C++) assume that the
division's result between two integers is another integer. :)
Input

The input contains a value of floating point (double precision).

Output

The output must be a message "VOLUME" like the following example with a space before and after
the equal signal. The value must be presented with 3 digits after the decimal point.

Input Samples Output Samples

3 VOLUME = 113.097

15 VOLUME = 14137.155

1523 VOLUME = 14797486501.627

URI Online Judge | 1012

Area
Adapted by Neilor Tonin, URI Brazil
Timelimit: 1

Make a program that reads three floating point values: A, B and C. Then, calculate and show:
a) the area of the rectangled triangle that has base A and height C.
b) the area of the radius's circle C. (pi = 3.14159)
c) the area of the trapezium which has A and B by base, and C by height.
d) the area of the square that has side B.
e) the area of the rectangle that has sides A and B.

Input

The input file contains three double values with one digit after the decimal point.

Output

The output file must contain 5 lines of data. Each line corresponds to one of the areas described
above, always with a corresponding message (in Portuguese) and one space between the two points
and the value. The value calculated must be presented with 3 digits after the decimal point.

Input Samples Output Samples

3.0 4.0 5.2 TRIANGULO: 7.800


CIRCULO: 84.949
TRAPEZIO: 18.200
QUADRADO: 16.000
RETANGULO: 12.000

12.7 10.4 15.2 TRIANGULO: 96.520


CIRCULO: 725.833
TRAPEZIO: 175.560
QUADRADO: 108.160
RETANGULO: 132.080
URI Online Judge | 1013

The Greatest
Adapted by Neilor Tonin, URI Brazil

Timelimit: 1

Make a program that reads 3 integer values and present the greatest one followed by the message
"eh o maior". Use the following formula:

Input

The input file contains 3 integer values.

Output

Print the greatest of these three values followed by a space and the message eh o maior.

Input Samples Output Samples

7 14 106 106 eh o maior

217 14 6 217 eh o maior


URI Online Judge | 1014

Consumption
Adapted by Neilor Tonin, URI Brazil

Timelimit: 1

Calculate a car's average consumption being provided the total distance traveled (in Km) and the
spent fuel total (in liters).

Input

The input file contains two values: one integer value X representing the total distance (in Km) and the
second one is a floating point number Y representing the spent fuel total, with a digit after the decimal
point.

Output

Present a value that represents the average consumption of a car with 3 digits after the decimal point,
followed by the message "km/l".

Input Sample Output Sample

500 14.286 km/l


35.0

2254 18.119 km/l


124.4

4554 9.802 km/l


464.6
URI Online Judge | 1015

Distance Between Two Points


Adapted by Neilor Tonin, URI Brazil

Timelimit: 1

Read the four values corresponding to the x and y axes of two points in the plane, p1 (x1, y1) and p2
(x2, y2) and calculate the distance between them, showing four decimal places after the comma,
according to the formula:

Distance =

Input

The input file contains two lines of data. The first one contains two double values: x1 y1 and the
second one also contains two double values with one digit after the decimal point: x2 y2.

Output

Calculate and print the distance value using the provided formula, with 4 digits after the decimal point.

Input Sample Output Sample

1.0 7.0 4.4721


Input Sample Output Sample

5.0 9.0

-2.5 0.4 16.1484


12.1 7.3

2.5 -0.4 16.4575


-12.2 7.0

URI Online Judge | 1016

Distance
Adapted by Neilor Tonin, URI Brazil

Timelimit: 1

Two cars (X and Y) leave in the same direction. The car X leaves with a constant speed of 60 km/h
and the car Y leaves with a constant speed of 90 km / h.

In one hour (60 minutes) the car Y can get a distance of 30 kilometers from the X car, in other words,
it can get away one kilometer for each 2 minutes.
Read the distance (in km) and calculate how long it takes (in minutes) for the car Y to take this
distance in relation to the other car.

Input

The input file contains 1 integer value.

Output

Print the necessary time followed by the message " minutos" that means minutes in Portuguese.

Input Sample Output Sample

30 60 minutos

110 220 minutos

7 14 minutos

URI Online Judge | 1017

Fuel Spent
Adapted by Neilor Tonin, URI Brazil
Timelimit: 1

Little John wants to calculate and show the amount of spent fuel liters on a trip, using a car that does
12 Km/L. For this, he would like you to help him through a simple program. To perform the calculation,
you have to read spent time (in hours) and the same average speed (km/h). In this way, you can get
distance and then, calculate how many liters would be needed. Show the value with three decimal
places after the point.

Input

The input file contains two integers. The first one is the spent time in the trip (in hours). The second
one is the average speed during the trip (in Km/h).

Output

Print how many liters would be needed to do this trip, with three digits after the decimal point.

Input Sample Output Sample

10 70.833
85

2 15.333
92

22 122.833
67
URI Online Judge | 1018

Banknotes
Adapted by Neilor Tonin, URI Brazil

Timelimit: 1

In this problem you have to read an integer value and calculate the smallest possible number of
banknotes in which the value may be decomposed. The possible banknotes are 100, 50, 20, 10, 5, 2
e 1. Print the read value and the list of banknotes.

Input

The input file contains an integer value N (0 < N < 1000000).

Output

Print the read number and the minimum quantity of each necessary banknotes in Portuguese
language, as the given example. Do not forget to print the end of line after each line, otherwise you
will receive Presentation Error.

Input Sample Output Sample

576 576
5 nota(s) de R$ 100,00
1 nota(s) de R$ 50,00
1 nota(s) de R$ 20,00
0 nota(s) de R$ 10,00
1 nota(s) de R$ 5,00
0 nota(s) de R$ 2,00
1 nota(s) de R$ 1,00

11257 11257
112 nota(s) de R$ 100,00
1 nota(s) de R$ 50,00
0 nota(s) de R$ 20,00
0 nota(s) de R$ 10,00
1 nota(s) de R$ 5,00
1 nota(s) de R$ 2,00
0 nota(s) de R$ 1,00

503 503
5 nota(s) de R$ 100,00
0 nota(s) de R$ 50,00
0 nota(s) de R$ 20,00
0 nota(s) de R$ 10,00
0 nota(s) de R$ 5,00
1 nota(s) de R$ 2,00
1 nota(s) de R$ 1,00

URI Online Judge | 1019

Time Conversion
Adapted by Neilor Tonin, URI Brazil

Timelimit: 1

Read an integer value, which is the duration in seconds of a certain event in a factory, and inform it
expressed in hours:minutes:seconds.

Input

The input file contains an integer N.

Output

Print the read time in the input file (seconds) converted in hours:minutes:seconds like the following
example.

Input Sample Output Sample

556 0:9:16

1 0:0:1
140153 38:55:53

URI Online Judge | 1020

Age in Days
Adapted by Neilor Tonin, URI Brazil

Timelimit: 1

Read an integer value corresponding to a person's age (in days) and print it in years, months and
days, followed by its respective message ano(s), mes(es), dia(s).

Note: only to facilitate the calculation, consider the whole year with 365 days and 30 days every
month. In the cases of test there will never a situation that allows 12 months and some days, like 360,
363 or 364. This is just an exercise for the purpose of testing simple mathematical reasoning.

Input

The input file contains 1 integer value.

Output
Print the output, like the following example.

Input Sample Output Sample

400 1 ano(s)
1 mes(es)
5 dia(s)

800 2 ano(s)
2 mes(es)
10 dia(s)

30 0 ano(s)
1 mes(es)
0 dia(s)

URI Online Judge | 1021

Banknotes and Coins

Read a value of floating point with two decimal places. This represents a monetary value. After this,
calculate the smallest possible number of notes and coins on which the value can be decomposed.
The considered notes are of 100, 50, 20, 10, 5, 2. The possible coins are of 1, 0.50, 0.25, 0.10, 0.05
and 0.01. Print the message NOTAS: followed by the list of notes and the message MOEDAS:
followed by the list of coins.

Input
The input file contains a value of floating point N (0 N 1000000.00).

Output

Print the minimum quantity of banknotes and coins necessary to change the initial value, as the given
example.

Input Sample Output Sample

576.73 NOTAS:
5 nota(s) de R$ 100.00
1 nota(s) de R$ 50.00
1 nota(s) de R$ 20.00
0 nota(s) de R$ 10.00
1 nota(s) de R$ 5.00
0 nota(s) de R$ 2.00
MOEDAS:
1 moeda(s) de R$ 1.00
1 moeda(s) de R$ 0.50
0 moeda(s) de R$ 0.25
2 moeda(s) de R$ 0.10
0 moeda(s) de R$ 0.05
3 moeda(s) de R$ 0.01

4.00 NOTAS:
0 nota(s) de R$ 100.00
0 nota(s) de R$ 50.00
0 nota(s) de R$ 20.00
0 nota(s) de R$ 10.00
0 nota(s) de R$ 5.00
2 nota(s) de R$ 2.00
MOEDAS:
0 moeda(s) de R$ 1.00
0 moeda(s) de R$ 0.50
0 moeda(s) de R$ 0.25
0 moeda(s) de R$ 0.10
0 moeda(s) de R$ 0.05
0 moeda(s) de R$ 0.01

91.01 NOTAS:
0 nota(s) de R$ 100.00
1 nota(s) de R$ 50.00
2 nota(s) de R$ 20.00
0 nota(s) de R$ 10.00
0 nota(s) de R$ 5.00
0 nota(s) de R$ 2.00
MOEDAS:
1 moeda(s) de R$ 1.00
0 moeda(s) de R$ 0.50
0 moeda(s) de R$ 0.25
0 moeda(s) de R$ 0.10
0 moeda(s) de R$ 0.05
1 moeda(s) de R$ 0.01
URI Online Judge | 1035

Selection Test 1
Adapted by Neilor Tonin, URI Brazil

Timelimit: 1

Read 4 integer values A, B, C and D. Then if B is greater than C and D is greater than A and if the
sum of C and D is greater than the sum of A and B and if C and D were positives values and if A is
even, write the message Valores aceitos (Accepted values). Otherwise, write the
message Valores nao aceitos (Values not accepted).

Input

Four integer numbers A, B, C and D.

Output

Show the corresponding message after the validation of the values.

Input Sample Output Sample

5 6 7 8 Valores nao aceitos

2 3 2 6 Valores aceitos
URI Online Judge | 1036

Bhaskara's Formula
Adapted by Neilor Tonin, URI Brazil

Timelimit: 1

Read 3 floating-point numbers. After, print the roots of bhaskaras formula. If it's impossible to
calculate the roots because a division by zero or a square root of a negative number, presents the
message Impossivel calcular.

Input

Read 3 floating-point numbers A, B and C.

Output

Print the result with 5 digits after the decimal point or the message if it is impossible to calculate.

Input Samples Output Samples

10.0 20.1 5.1 R1 = -0.29788


R2 = -1.71212

0.0 20.0 5.0 Impossivel calcular

10.3 203.0 5.0 R1 = -0.02466


R2 = -19.68408

10.0 3.0 5.0 Impossivel calcular


URI Online Judge | 1037

Interval
Adapted by Neilor Tonin, URI Brazil

Timelimit: 1

You must make a program that read a float-point number and print a message saying in which of
following intervals the number belongs: [0,25] (25,50], (50,75], (75,100]. If the read number is less
than zero or greather than 100, the program must print the message Fora de intervalo that means
"Out of Interval".

The symbol '(' represents greather than. For example:


[0,25] indicates numbers between 0 and 25.0000, including both.
(25,50] indicates numbers greather than 25 (25.00001) up to 50.0000000.

Input

The input file contains a floating-point number.

Output

The output must be a message like following example.


Input Sample Output Sample

25.01 Intervalo (25,50]

25.00 Intervalo [0,25]

100.00 Intervalo (75,100]

-25.02 Fora de intervalo

URI Online Judge | 1038

Snack
Adapted by Neilor Tonin, URI Brazil

Timelimit: 1

Using the following table, write a program that reads a code and the amount of an item. After, print the
value to pay. This is a very simple program with the only intention of practice of selection commands.
Input

The input file contains two integer numbers X and Y. X is the product code and Y is the quantity of this
item according to the above table.

Output

The output must be a message "Total: R$ " followed by the total value to be paid, with 2 digits after the
decimal point.

Input Sample Output Sample

3 2 Total: R$ 10.00

4 3 Total: R$ 6.00

2 3 Total: R$ 13.50

URI Online Judge | 1040


Average 3
Adapted by Neilor Tonin, URI Brazil

Timelimit: 1

Read four numbers (N1, N2, N3, N4), which one with 1 digit after the decimal point, corresponding to 4
scores obtained by a student. Calculate the average with weights 2, 3, 4 e 1 respectively, for these 4
scores and print the message "Media: " (Average), followed by the calculated result. If the average
was 7.0 or more, print the message "Aluno aprovado." (Approved Student). If the average was less
than 5.0, print the message: "Aluno reprovado." (Reproved Student). If the average was between 5.0
and 6.9, including these, the program must print the message "Aluno em exame." (In exam student).

In case of exam, read one more score. Print the message "Nota do exame: " (Exam score) followed
by the typed score. Recalculate the average (sum the exam score with the previous calculated
average and divide by 2) and print the message Aluno aprovado. (Approved student) in case of
average 5.0 or more) or "Aluno reprovado." (Reproved student) in case of average 4.9 or less. For
these 2 cases (approved or reproved after the exam) print the message "Media final: " (Final average)
followed by the final average for this student in the last line.

Input

The input contains four floating point numbers that represent the students' grades.

Output

Print all the answers with one digit after the decimal point.

Input Sample Output Sample

2.0 4.0 7.5 8.0 Media: 5.4


6.4 Aluno em exame.
Nota do exame: 6.4
Aluno aprovado.
Media final: 5.9

2.0 6.5 4.0 9.0 Media: 4.8


Aluno reprovado.

9.0 4.0 8.5 9.0 Media: 7.3


Aluno aprovado.

URI Online Judge | 1041

Coordinates of a Point
Adapted by Neilor Tonin, URI Brazil

Timelimit: 1

Write an algorithm that reads two floating values (x and y), which should represent the coordinates of
a point in a plane. Next, determine which quadrant the point belongs, or if you are over one of the
Cartesian axes or the origin (x = y = 0).

If the point is at the origin, write the message "Origem".

If the point is over X axis write "Eixo X", else if the point is over Y axis write "Eixo Y".

Input

The input contains the coordinates of a point.

Output

The output should display the quadrant in which the point is.
Input Sample Output Sample

4.5 -2.2 Q4

0.1 0.1 Q1

0.0 0.0 Origem

URI Online Judge | 1042

Simple Sort
Adapted by Neilor Tonin, URI Brazil

Timelimit: 1

Read three integers and sort them in ascending order. After, print these values in ascending order, a
blank line and then the values in the sequence as they were readed.

Input

The input contains three integer numbers.

Output

Present the output as requested above.

Input Sample Output Sample

7 21 -14 -14
Input Sample Output Sample

7
21

7
21
-14

-14 21 7 -14
7
21

-14
21
7

URI Online Judge | 1043

Triangle
Adapted by Neilor Tonin, URI Brazil

Timelimit: 1
Read three point floating values (A, B and C) and verify if is possible to make a triangle with them. If it
is possible, calculate the perimeter of the triangle and print the message:

Perimetro = XX.X

If it is not possible, calculate the area of the trapezium which basis A and B and C as height, and print
the message:

Area = XX.X

Input

The input file has tree floating point numbers.

Output

Print the result with one digit after the decimal point.

Input Sample Output Sample

6.0 4.0 2.0 Area = 10.0

6.0 4.0 2.1 Perimetro = 12.1


URI Online Judge | 1044

Multiples
Adapted by Neilor Tonin, URI Brazil

Timelimit: 1

Read two nteger values (A and B). After, the program should print the message "Sao Multiplos" (are
multiples) or "Nao sao Multiplos" (arent multiples), corresponding to the read values.

Input

The input has two integer numbers.

Output

Print the relative message to the input as stated above.

Input Sample Output Sample

6 24 Sao Multiplos

6 25 Nao sao Multiplos


URI Online Judge | 1045

Triangle Types
Adapted by Neilor Tonin, URI Brazil
Timelimit: 1

Read 3 double numbers (A, B and C) representing the sides of a triangle and arrange them in
decreasing order, so that the side A is the biggest of the three sides. Next, determine the type of
triangle that they can make, based on the following cases always writing an appropriate message:

if A B + C, write the message: NAO FORMA TRIANGULO

if A2 = B2 + C2, write the message: TRIANGULO RETANGULO

if A2 > B2 + C2, write the message: TRIANGULO OBTUSANGULO

if A2 < B2 + C2, write the message: TRIANGULO ACUTANGULO

if the three sides are the same size, write the message: TRIANGULO EQUILATERO

if only two sides are the same and the third one is different, write the message: TRIANGULO
ISOSCELES

Input
The input contains three double numbers, A (0 < A) , B (0 < B) and C (0 < C).

Output
Print all the classifications of the triangle presented in the input.

Input Samples Output Samples

7.0 5.0 7.0 TRIANGULO ACUTANGULO


TRIANGULO ISOSCELES
6.0 6.0 10.0 TRIANGULO OBTUSANGULO
TRIANGULO ISOSCELES
6.0 6.0 6.0 TRIANGULO ACUTANGULO
TRIANGULO EQUILATERO
5.0 7.0 2.0 NAO FORMA TRIANGULO
6.0 8.0 10.0 TRIANGULO RETANGULO

URI Online Judge | 1046

Game Time
Adapted by Neilor Tonin, URI Brazil

Timelimit: 1

Read the start time and end time of a game, in hours. Then calculate the duration of the game,
knowing that the game can begin in a day and finish in another day, with a maximum duration of 24
hours. The message must be printed in portuguese O JOGO DUROU X HORA(S) that means THE
GAME LASTED X HOUR(S)

Input

Two integer numbers representing the start and end time of a game.

Output

Print the duration of the game as in the sample output.

Input Sample Output Sample

16 2 O JOGO DUROU 10 HORA(S)

0 0 O JOGO DUROU 24 HORA(S)

2 16 O JOGO DUROU 14 HORA(S)


URI Online Judge | 1047

Game Time with Minutes


Adapted by Neilor Tonin, URI Brazil

Timelimit: 1

Read the start time and end time of a game, in hours and minutes (initial hour, initial minute, final hour,
final minute). Then print the duration of the game, knowing that the game can begin in a day and finish
in another day,

Obs.: With a maximum game time of 24 hours and the minimum game time of 1 minute.

Input

Four integer numbers representing the start and end time of the game.

Output

Print the duration of the game in hours and minutes, in this format: O JOGO DUROU XXX HORA(S)
E YYY MINUTO(S) . Which means: the game lasted XXX hour(s) and YYY minutes.
Input Sample Output Sample

7 8 9 10 O JOGO DUROU 2 HORA(S) E 2


MINUTO(S)

7 7 7 7 O JOGO DUROU 24 HORA(S) E 0


MINUTO(S)

7 10 8 9 O JOGO DUROU 0 HORA(S) E 59


MINUTO(S)

URI Online Judge | 1048

Salary Increase
By Neilor Tonin, URI Brazil

Timelimit: 1

The company ABC decided to give a salary increase to its employees, according to the following
table:
Read the employee's salary, calculate and print the new employee's salary, as well the money earned
and the increase percentual obtained by the employee, with corresponding messages in Portuguese,
as the below example.

Input

The input contains only a floating-point number, with 2 digits after the decimal point.

Output

Print 3 messages followed by the corresponding numbers (see example) informing the new salary, the
among of money earned and the percentual obtained by the employee. Note:
Novo salario: means "New Salary"
Reajuste ganho: means "Money earned"
Em percentual: means "In percentage"

Input Sample Output Sample

400.00 Novo salario: 460.00


Reajuste ganho: 60.00
Em percentual: 15 %

800.01 Novo salario: 880.01


Reajuste ganho: 80.00
Em percentual: 10 %

2000.00 Novo salario: 2140.00


Reajuste ganho: 140.00
Em percentual: 7 %

URI Online Judge | 1049


Animal
By Neilor Tonin, URI Brazil

Timelimit: 1

In this problem, your job is to read three Portuguese words. These words define an animal according
to the table below, from left to right. After, print the chosen animal defined by these three words.

Input

The input contains 3 words, one by line, that will be used to identify the animal, according to the above
table, with all letters in lowercase.

Output

Print the animal name according to the given input.

Input Samples Output Samples

vertebrado homem
mamifero
onivoro

vertebrado aguia
ave
carnivoro

invertebrado minhoca
anelideo
onivoro

URI Online Judge | 1050

DDD
Adapted by Neilor Tonin, URI Brazil

Timelimit: 1

Read an integer number that is the code number for phone dialing. Then, print the destination
according to the following table:

If the input number isnt found in the above table, the output must be:
DDD no cadastrado
That means DDD not found in Portuguese language.

Input

The input consists in a unique integer number.

Output

Print the city name corresponding to the input DDD. Print DDD nao cadastrado if doesn't exist
corresponding DDD to the typed number.
Input Sample Output Sample

11 Sao Paulo

URI Online Judge | 1051

Taxes
By Neilor Tonin, URI Brazil

Timelimit: 1

In an imaginary country called Lisarb, all the people are very happy to pay their taxes because they
know that doesnt exist corrupt politicians and the taxes are used to benefit the population, without any
misappropriation. The currency of this country is Rombus, whose symbol is R$.

Read a value with 2 digits after the decimal point, equivalent to the salary of a Lisarb inhabitant. Then
print the due value that this person must pay of taxes, according to the table below.

Remember, if the salary is R$ 3,002.00 for example, the rate of 8% is only over R$ 1,000.00, because
the salary from R$ 0.00 to R$ 2,000.00 is tax free. In the follow example, the total rate is 8% over R$
1000.00 + 18% over R$ 2.00, resulting in R$ 80.36 at all. The answer must be printed with 2 digits
after the decimal point.
Input

The input contains only a float-point number, with 2 digits after the decimal point.

Output

Print the message "R$" followed by a blank space and the total tax to be payed, with two digits after
the decimal point. If the value is up to 2000, print the message "Isento".

Input Samples Outputs Samples

3002.00 R$ 80.36

1701.12 Isento

4520.00 R$ 355.60

URI Online Judge | 1052

Month
Adapted by Neilor Tonin, URI Brazil

Timelimit: 1

Read an integer number between 1 and 12, including. Corresponding to this number, you must print
the month of the year, in english, with the first letter in uppercase.

Input

The input contains only an integer number.

Output

Print the name of the month according to the input number, with the first letter in uppercase.
Input Sample Output Sample

4 April

URI Online Judge | 1059

Even Numbers
Adapted by Neilor Tonin, URI Brazil

Timelimit: 1

Write a program that prints all even numbers between 1 and 100, including them if it is the case.

Input

In this extremely simple problem there is no input.


Output

Print all even numbers between 1 and 100, including them, one by row.

Input Sample Output Sample

2
4
6
...
100

URI Online Judge | 1060

Positive Numbers
Adapted by Neilor Tonin, URI Brazil

Timelimit: 1
Write a program that reads 6 numbers. These numbers will only be positive or negative (disregard null
values). Print the total number of positive numbers.

Input

Six numbers, positive and/or negative.

Output

Print a message with the total number of positive numbers.

Input Sample Output Sample

7 4 valores positivos
-5
6
-3.4
4.6
12

URI Online Judge | 1061

Event Time
Adapted by Neilor Tonin, URI Brazil

Timelimit: 1

Peter is organizing an event in his University. The event will be in April month, beginning and finishing
within April month. The problem is: Peter wants to calculate the event duration in seconds, knowing
obviously the begin and the end time of the event.

You know that the event can take from few seconds to some days, so, you must help Peter to
compute the total time, in seconds, corresponding to duration of the event.

Input

The first line of the input contains information about the beginning day of the event in the format: Dia
xx. The next line contains the start time of the event in the format presented in the sample input.
Follow 2 input lines with same format, corresponding to the end of the event.

Output

Your program must print the following output, one information by line, considering that if any
information is null for example, the number 0 must be printed in place of W, X, Y or Z:

W dia(s)
X hora(s)
Y minuto(s)
Z segundo(s)

Obs: Consider that the event of the test case have the minimum duration of one minute. dia means
day, hora means hour, minuto means minute and Segundo means second in Portuguese.

Input Sample Output Sample

Dia 5 3 dia(s)
08 : 12 : 23 22 hora(s)
Dia 9 1 minuto(s)
06 : 13 : 23 0 segundo(s)
URI Online Judge | 1064

Positives and Average


Adapted by Neilor Tonin, URI Brazil

Timelimit: 1

Read 6 values that can be floating point numbers. After, print how many of them were positive. In the
next line, print the average of all positive values typed, with one digit after the decimal point.

Input

The input consist in 6 numbers that can be integer or floating point values. At least one number will be
positive.

Output

The first output value is the amount of positive numbers. The next line should show the average
of the positive values typed.

Input Sample Output Sample

7 4 valores positivos
-5 7.4
6
-3.4
4.6
12
URI Online Judge | 1065

Even Between five Numbers


Adapted by Neilor Tonin, URI Brazil

Timelimit: 1

Make a program that reads five integer values. Count how many of these values are even and print
this information like the following example.

Input

The input will be 5 integer values.

Output

Print a message like the following example with all letters in lowercase, indicating how many even
numbers were typed.

Input Sample Output Sample

7 3 valores pares
-5
6
-4
12
URI Online Judge | 1066

Even, Odd, Positive and Negative


Adapted by Neilor Tonin, URI Brazil

Timelimit: 1

Make a program that reads five integer values. Count how many of these values are even, odd,
positive and negative. Print these information like following example.

Input

The input will be 5 integer values.

Output

Print a message like the following example with all letters in lowercase, indicating how many of these
values areeven, odd, positive and negative.

Input Sample Output Sample

-5 3 valor(es) par(es)
0 2 valor(es) impar(es)
-3 1 valor(es) positivo(s)
-4 3 valor(es) negativo(s)
12
URI Online Judge | 1067

Odd Numbers
Adapted by Neilor Tonin, URI Brazil

Timelimit: 1

Read an integer value X (1 <= X <= 1000). Then print the odd numbers from 1 to X, each one in a
line, including X if is the case.

Input

The input will be an integer value.

Output

Print all odd values between 1 and X, including X if is the case.

Input Sample Output Sample

8 1
3
5
7
URI Online Judge | 1070

Six Odd Numbers


Adapted by Neilor Tonin, URI Brazil

Timelimit: 1

Read an integer value X and print the 6 consecutive odd numbers from X, a value per line,
including X if it is the case.

Input

The input will be a positive integer value.

Output

The output will be a sequence of six odd numbers.


Input Sample Output Sample

8 9
11
13
15
17
19

URI Online Judge | 1071

Sum of Consecutive Odd Numbers I


Adapted by Neilor Tonin, URI Brazil

Timelimit: 1

Read two integer values X and Y. Print the sum of all odd values between them.

Input
The input file contain two integer values.

Output

The program must print an integer number. This number is the sum off all odd values between both
input values that must fit in an integer number.

Sample Input Sample Output

6 5
-5

15 13
12

12 0
12

URI Online Judge | 1072


Interval 2
Adapted by Neilor Tonin, URI Brazil

Timelimit: 1

Read an integer N. This N will be the number of integer numbers X that will be read.

Print how many these numbers X are in the interval [10,20] and how many values are out of this
interval.

Input

The first line of input is an integer N (N < 10000), that indicates the total number of test cases.
Each case is an integer number X (-107 < X < 107).

Output

For each test case, print how many numbers are in and how many values are out of the interval.

Input Sample Output Sample

4 2 in
14 2 out
123
10
-25
URI Online Judge | 1073

Even Square
Adapted by Neilor Tonin, URI Brazil

Timelimit: 1

Read an integer N. Print the square of each one of the even values from 1 to N including N if it is the
case.

Input

The input contains an integer N (5 < N < 2000).

Output

Print the square of each one of the even values from 1 to N, as the given example.

Be carefull! Some language automaticly print 1e+006 instead 1000000. Please configure your
program to print the correct format setting the output precision.

Input Sample Output Sample

6 2^2 = 4
4^2 = 16
6^2 = 36
URI Online Judge | 1074

Even or Odd
Adapted by Neilor Tonin, URI Brazil

Timelimit: 1

Read an integer value N. After, read these N values and print a message for each value saying if this
value isodd, even, positive or negative. In case of zero (0), although the correct description would be
"EVEN NULL", because by definition zero is even, your program must print only "NULL", without
quotes.

Input

The first line of input is an integer N (N < 10000), that indicates the total number of test cases. Each
case is a integer number X (-107 < X <107)..

Output

For each test case, print a corresponding message, according to the below example. All messages
must be printed in uppercase letters and always will have one space between two words in the same
line.

Input Sample Output Sample

4 ODD NEGATIVE
-5 NULL
0 ODD POSITIVE
3 EVEN NEGATIVE
-4
URI Online Judge | 1075

Remaining 2
Adapted by Neilor Tonin, URI Brazil

Timelimit: 1

Read an integer N. Print all numbers between 1 and 10000, which divided by N will give the rest = 2.

Input

The input is an integer N (N < 10000)

Output

Print all numbers between 1 and 10000, which divided by n will give the rest = 2, one per line.

Input Sample Output Sample

13 2
15
28
41
...
URI Online Judge | 1078

Multiplication Table
Adapted by Neilor Tonin, URI Brazil

Timelimit: 1

Read an integer N (2 < N < 1000). Print the multiplication table of N.


1xN=N 2 x N = 2N ... 10 x N = 10N

Input

The input is an integer N (1 < N < 1000).

Output

Print the multiplication table of N., like the following example.

Input Sample Output Sample

140 1 x 140 = 140


2 x 140 = 280
Input Sample Output Sample

3 x 140 = 420
4 x 140 = 560
5 x 140 = 700
6 x 140 = 840
7 x 140 = 980
8 x 140 = 1120
9 x 140 = 1260
10 x 140 = 1400

URI Online Judge | 1079

Weighted Averages
Adapted by Neilor Tonin, URI Brazil

Timelimit: 1

Read an integer N, which represents the number of following test cases. Each test case consists of
three floating-point numbers, each one with one digit after the decimal point. Print the weighted
average for each of these sets of three numbers, considering that the first number has weight 2, the
second number has weight 3 and the third number has weight 5.

Input
The input file contains an integer number N in the first line. Each N following line is a test case with
three float-point numbers, each one with one digit after the decimal point.

Output

For each test case, print the weighted average according with below example.

Input Sample Output Sample

3 5.7
6.5 4.3 6.2 6.3
5.1 4.2 8.1 9.3
8.0 9.0 10.0

URI Online Judge | 1080

Highest and Position


Adapted by Neilor Tonin, URI Brazil

Timelimit: 1

Read 100 integer numbers. Print the highest read value and the input position.
Input

The input file contains 100 distinct positive integer numbers.

Output

Print the highest number read and the input position of this value, according to the given example.

Input Sample Output Sample

2 34565
113 4
45
34565
6
...
8

URI Online Judge | 1094

Experiments
Adapted by Neilor Tonin, URI Brazil

Timelimit: 1

Maria has just started as graduate student in a medical school and she's needing your help to
organize a laboratory experiment which she is responsible about. She wants to know, at the end of the
year, how many animals were used in this laboratory and the percentage of each type of animal is
used at all.

This laboratory uses in particular three types of animals: frogs, rats and rabbits. To obtain this
information, it knows exactly the number of experiments that were performed, the type and quantity of
each animal is used in each experiment.

Input

The first line of input contains an integer N indicating the number of test cases that follows. Each test
case contains an integer Amount (1 Amount 15) which represents the amount of animal used
and a characterType ('C', 'R' or 'S'), indicating the type of animal:
- C: Coelho (rabbit in portuguese)
- R: Rato (rat in portuguese)
- S: Sapo (frog in portuguese)

Output

Print the total of animals used, the total of each type of animal and the percentual of each one in
relation of the total of animals used. The percentual must be printed with 2 digits after the decimal
point.

Input Sample Output Sample

10 Total: 92 cobaias
10 C Total de coelhos: 29
6 R Total de ratos: 40
15 S Total de sapos: 23
5 C Percentual de coelhos: 31.52 %
14 R Percentual de ratos: 43.48 %
9 C Percentual de sapos: 25.00 %
6 R
8 S
5 C
14 R
URI Online Judge | 1095

Sequence IJ 1
Adapted by Neilor Tonin, URI Brazil

Timelimit: 1

Make a program that prints the sequence like the following example.

Input

This problem doesn't have input.

Output

Print the sequence like the example below.

Input Sample Output Sample

I=1 J=60
I=4 J=55
I=7 J=50
...
I=? J=0
URI Online Judge | 1096

Sequence IJ 2
Adapted by Neilor Tonin, URI Brazil

Timelimit: 1

Make a program that prints the sequence like the following exemple.

Input

This problem doesn't have input.

Output

Print the sequence like the example below.

Input Sample Output Sample

I=1 J=7
I=1 J=6
I=1 J=5
I=3 J=7
I=3 J=6
I=3 J=5
...
I=9 J=7
I=9 J=6
I=9 J=5
URI Online Judge | 1097

Sequence IJ 3
Adapted by Neilor Tonin, URI Brazil

Timelimit: 1

Make a program that prints the sequence like the following exemple.

Input

This problem doesn't have input.

Output

Print the sequence like the example below.

Input Sample Output Sample

I=1 J=7
I=1 J=6
I=1 J=5
I=3 J=9
I=3 J=8
I=3 J=7
...
I=9 J=15
I=9 J=14
Input Sample Output Sample

I=9 J=13

URI Online Judge | 1098

Sequence IJ 4
Adapted by Neilor Tonin, URI Brazil

Timelimit: 1

Make a program that prints the sequence like the following example.

Input

This problem doesn't have input.

Output

Print the sequence like the example below.


Input Sample Output Sample

I=0 J=1
I=0 J=2
I=0 J=3
I=0.2 J=1.2
I=0.2 J=2.2
I=0.2 J=3.2
.....
I=2 J=?
I=2 J=?
I=2 J=?

URI Online Judge | 1099

Sum of Consecutive Odd Numbers II


Adapted by Neilor Tonin, URI Brazil

Timelimit: 1

Read an integer N that is the number of test cases. Each test case is a line containing two integer
numbers Xand Y. Print the sum of all odd values between them, not including X and Y.
Input

The first line of input is an integer N that is the number of test cases that follow. Each test case is a
line containing two integer X and Y.

Output

Print the sum of all odd numbers between X and Y.

Input Sample Output Sample

7 0

4 5 11

13 10 5

6 4 0

3 3 0

3 5 0

3 4 12

3 8
URI Online Judge | 1101

Sequence of Numbers and Sum


Adapted by Neilor Tonin, URI Brazil

Timelimit: 1

Read an undetermined number of pairs values M and N (stop when any of these values is less or
equal to zero). For each pair, print the sequence from the smallest to the biggest (including both) and
the sum of consecutive integers between them (including both).

Input

The input file contains pairs of integer values M and N. The last line of the file contains a number zero
or negative, or both.

Output

For each pair of numbers, print the sequence from the smallest to the biggest and the sum of these
values, as shown below.

Input Sample Output Sample

5 2 2 3 4 5 Sum=14
6 3 3 4 5 6 Sum=18
5 0
URI Online Judge | 1113

Ascending and Descending


Adapted by Neilor Tonin, URI Brazil

Timelimit: 1

Read an undetermined number of pairs of integer values. Write a message for each pair indicating if
this two numbers are in ascending or descending order.

Input

The input file contains several test cases. Each test case contains two integer numbers X and Y. The
input will finished when X = Y.

Output

For each test case print Crescente, if the values X and Y are in ascending order, otherwise print
Decrescente.

Input Sample Output Sample

5 4 Decrescente
7 2 Decrescente
3 8 Crescente
2 2

Adjustments and translation by Cssio Favaretto.


URI Online Judge | 1114

Fixed Password
Adapted by Neilor Tonin, URI Brazil

Timelimit: 1

Write a program that keep reading a password until it is valid. For each wrong password read, write
the message "Senha invlida". When the password is typed correctly print the message "Acesso
Permitido" and finished the program. The correct password is the number 2002.

Input

The input file contains several tests cases. Each test case contains only an integer number.

Output

For each number read print a message corresponding to the description of the problem.

Input Sample Output Sample

2200 Senha Invalida


1020 Senha Invalida
2022 Senha Invalida
2002 Acesso Permitido

Adjustments by Cssio Favaretto.


URI Online Judge | 1115

Quadrant
Adapted by Neilor Tonin, URI Brazil

Timelimit: 1

Write a program to read the coordinates (X, Y) of an indeterminate number of points in Cartesian
system. For each point write the quadrant to which it belongs. The program finish when at least one of
two coordinates is NULL (in this situation without writing any message).

Input

The input contains several tests cases. Each test case contains two integer numbers.

Output

For each test case, print the corresponding quadrant which these coordinates belong, as in the
example.
Input Sample Output Sample

2 2 primeiro
3 -2 quarto
-8 -1 terceiro
-7 1 segundo
0 2

Adjustments and translating by Cssio Favaretto.

URI Online Judge | 1116

Dividing X by Y
Adapted by Neilor Tonin, URI Brazil

Timelimit: 2

Write a program that read two numbers X and Y and print the result of dividing the X by Y. If it's not
possible, print the message "diviso impossvel".

Input
The input contains an integer number N. This N is the quantity of pairs of integer numbers X and Y
read (dividend and divisor).

Output

For each test case print the result of this division with one digit after the decimal point, or diviso
impossvel if it isn't possible to perform the calculation.

Obs.: Be carefull. The division between two integers in some languages generates another integer.
Use cast:)

Input Sample Output Sample

3 -1.5
3 -2 divisao impossivel
-8 0 0.0
0 8

Adjustments and translation by Cssio Favaretto.

URI Online Judge | 1117

Score Validation
Adapted by Neilor Tonin, URI Brazil

Timelimit: 1

Write a program that reads two scores of a student. Calculate and print the average of these scores.
Your program must accept just valid scores [0..10]. Each score must be validated separately.

Input

The input file contains many floating-point numbers, positive or negative. The program execution will
be finished after the input of two valid scores.

Output

When an invalid score is read, you should print the message "nota invlida".
After the input of two valid scores, the message "mdia = " must be printed followed by the average of
the student. The average must be printed with 2 numbers after the decimal point.

Input Sample Output Sample

-3.5 nota invalida


3.5 nota invalida
11.0 media = 6.75
10.0

Thanks to Cssio F.
URI Online Judge | 1118

Several Scores with Validation


By Neilor Tonin, URI Brazil

Timelimit: 1

Write an program to read two scores of a student. Calculate and print the semester average. The
program must accept only valid scores (a score must fit in the range [0.10]). Each score must be
validated separately.

The program must print a message "novo clculo (1-sim 2-nao)" that means "new calculate (1-yes 2-
no)". After, the input will be (1 or 2). 1 means a new calculation, 2 means that the execution must be
finished.

Input

The input file contains several positive or negative floating-point (double) values. After the input of 2
valid scores, an integer number X will be read. Your program must stop when X = 2.

Output

If an invalid score is read, must be printed the message "nota invlida". When two valid scores are
read, the message "media = " must be printed folowed by the average between these 2 scores. The
message "novo clculo (1-sim 2-nao)" must be printed after reading X. This message should be
displayed again if the standard input number for X is less than 1 or greater than 2, as example below.

The output average must be printed with 2 digits after the decimal point.

Input Sample Output Sample

-3.5 nota invalida


3.5 nota invalida
11.0 media = 6.75
10.0 novo calculo (1-sim 2-nao)
4 novo calculo (1-sim 2-nao)
1 media = 8.50
8.0 novo calculo (1-sim 2-nao)
9.0
2
Thanks to Cssio F.

URI Online Judge | 1131

Grenais
Adapted by Neilor Tonin, URI Brazil

Timelimit: 1

The Federao Gacha de Futebol invited you to write a program to present a statistical result of
several GRENAIS. Write a program that read the number of goals scored by Inter and the number of
goals scored by Gremio in a GRENAL. Write the message "Novo grenal (1-sim 2-nao)" and request a
response. If the answer is 1, two new numbers must be read (another input case) asking the number
of goals scored by the teams in a new departure, otherwise the program must be finished, printing:

- How many GRENAIS were part of the statistics.


- The number of victories of Inter.
- The number of victories of Gremio.
- The number of Draws.
- A message indicating the team that won the largest number of GRENAIS (or the message: "No
houve vencedor" if both team won the same quantity of GRENAIS).

Input

The input contains two integer values, corresponding to the goals scored by both teams. Then there is
an integer (1 or 2), corresponding to the repetition of the algorithm.

Output

After each reading of the goals it must be printed the message "Novo grenal (1-sim 2-nao)". When the
program is finished, the program must print the statistics as the example below.
Input Sample Output Sample

3 2 Novo grenal (1-sim 2-nao)


1 Novo grenal (1-sim 2-nao)
2 3 Novo grenal (1-sim 2-nao)
1 3 grenais
3 1 Inter:2
2 Gremio:1
Empates:0
Inter venceu mais

Thanks to Cssio F.

URI Online Judge | 1132

Multiples of 13
Adapted by Neilor Tonin, URI Brazil

Timelimit: 1

Write a program that reads two integer numbers X and Y and calculate the sum of all number not
divisible by 13 between them, including both.

Input

The input file contains 2 integer numbers X and Y without any order.

Output

Print the sum of all numbers between X and Y not divisible by 13, including them if it is the case.
Input Sample Output Sample

100 13954
200

Thanks to Cssio F.

URI Online Judge | 1133

Rest of a Division
Adapted by Neilor Tonin, URI Brazil

Timelimit: 1

Write a program that reads two integer numbers X and Y. Print all numbers between X and Y which
dividing it by 5 the rest is equal to 2 or equal to 3.

Input
The input file contains 2 integer numbers X and Y without any order.

Output

Print all numbers according to above description, always in ascending order.

Input Sample Output Sample

10 12
18 13
17

URI Online Judge | 1134

Type of Fuel
Adapted by Neilor Tonin, URI Brazil

Timelimit: 1
A gas station wants to determine which of their products is the preference of their customers. Write a
program to read the type of fuel supplied (coded as follows: 1. Alcohol 2. Gasoline 3. Diesel 4. End). If
you enter an invalid code (outside the range of 1 to 4) must be requested a new code (valid until). The
program will end when the inserted code is the number 4.

Input

The input contains only integer and positive values.

Output

It should be written the message: "MUITO OBRIGADO" and the amount of customers who fueled
each fuel type, as an example.

Input Sample Output Sample

8 MUITO OBRIGADO
1 Alcool: 1
7 Gasolina: 2
2 Diesel: 0
2
4

Thanks to Cssio F.

URI Online Judge | 1142


PUM
Adapted by Neilor Tonin, URI Brazil

Timelimit: 1

Write a program that reads an integer N. This N is the number of output lines printed by this program.

Input

The input file contains an integer N.

Output

Print the output according to the given example.

Input Sample Output Sample

7 1 2 3 PUM
5 6 7 PUM
9 10 11 PUM
13 14 15 PUM
17 18 19 PUM
21 22 23 PUM
25 26 27 PUM
URI Online Judge | 1143

Squared and Cubic


Adapted by Neilor Tonin, URI Brazil

Timelimit: 1

Write a program that reads an integer N (1 < N < 1000). This N is the number of output lines printed
by this program.

Input

The input file contains an integer N.

Output

Print the output according to the given example.

Input Sample Output Sample

5 1 1 1
2 4 8
3 9 27
4 16 64
5 25 125

Thanks to Cssio F.
URI Online Judge | 1144

Logical Sequence
Adapted by Neilor Tonin, URI Brazil

Timelimit: 1

Write a program that reads an integer N. N * 2 lines must be printed by this program according to the
example below. For numbers with more than 6 digits, all digits must be printed (no cientific notation
allowed).

Input

The input file contains an integer N (1 < N < 1000).

Output

Print the output according to the given example.

Input Sample Output Sample

5 1 1 1
1 2 2
2 4 8
2 5 9
3 9 27
3 10 28
4 16 64
4 17 65
5 25 125
5 26 126
Thanks to Cssio F.

URI Online Judge | 1145

Logical Sequence 2
Adapted by Neilor Tonin, URI Brazil

Timelimit: 1

Write an program that reads two numbers X and Y (X < Y). After this, show a sequence of 1 to y,
passing to the next line to each X numbers.

Input

The input contains two integer numbers X (1 < X < 20) and Y (X < Y < 100000).

Output

Each sequence must be printed in one line, with a blank space between each number, like the
following example.

Input Sample Output Sample

3 99 1 2 3
4 5 6
7 8 9
Input Sample Output Sample

10 11 12
...
97 98 99

Thanks to Cssio F.

URI Online Judge | 1146

Growing Sequences
Adapted by Neilor Tonin, URI Brazil

Timelimit: 2

Your program must read an integer X indefinited times (the program must stop when X is equal to
zero). For each X print the sequence from 1 to X, with one space between each one of these
numbers.

PS: Be carefull. Don't leave any space after the last number of each line, otherwise you'll
get Presentation Error.

Input
The input file contains many integer numbers. The last one is zero.

Output

For each number N of the input file, one output line must be printed, from 1 to N like the following
example. Be careful with blank spaces after the last line number.

Input Sample Output Sample

5 1 2 3 4 5
10 1 2 3 4 5 6 7 8 9 10
3 1 2 3
0

URI Online Judge | 1149

Summing Consecutive Integers


Adapted by Neilor Tonin, URI Brazil

Timelimit: 1

Write an algorithm to read a value A and a value N. Print the sum of N numbers from A (inclusive).
While N is negative or ZERO, a new N (only N) must be read. All input values are in the same line.
Input

The input contains only integer values, can be positive or negative.

Output

The output contains only an integer value.

Input Sample Output Sample

3 2 7

Thanks to Cssio F.

URI Online Judge | 1150

Exceeding Z
Adapted by Neilor Tonin, URI Brazil

Timelimit: 1

Write a program that reads two integers: X and Z (Z must be read as many times as necessary, until a
number greater than X is read). Count how many integers must be summed in sequence (from and
including X) so that the sum exceeds Z the minimum possible and write this number.

The input may have, for example, the numbers 21 21 15 30. In this case, the number 21 is assumed
for X, The numbers 21 and 15 must be ignored because they are smaller or equal to X. The number
30 is within the specification (greater than X) and is valid. So, the final result must be 2 for this test
case, because the sum (21 + 22) is bigger than 30.

Input

The input contains only integer values, one per line, which may be positive or negative. The first
number is the value of X. The next line will contain Z. If Z does not meet the specification of the
problem, it should be read again, as many times as necessary.

Output

Print a line with an integer number representing the among of integer numbers that must be summed.

Input Sample Output Sample

3 5
1
20
URI Online Judge | 1151

Easy Fibonacci
Adapted by Neilor Tonin, URI Brazil

Timelimit: 1

The following sequence of numbers 0 1 1 2 3 5 8 13 21 ... is known as the Fibonacci Sequence.


Thereafter, each number after the first 2 is equal to the sum of the previous two numbers. Write an
algorithm that reads an integer N (N < 46) and that print the first N numbers of this sequence.

Input

The input file contains an integer number N (0 < N < 46).

Output

The numbers should be printed on the same line, separated by a blank space. There is no space after
the last number.

Thanks to Cssio F.

Input Sample Output Sample

5 0 1 1 2 3
URI Online Judge | 1153

Simple Factorial
Adapted by Neilor Tonin, URI Brazil

Timelimit: 1

Read a value N. Calculate and write its corresponding factorial. Factorial of N = N * (N-1) * (N-2) * (N-
3) * ... * 1.

Input

The input contains an integer value N (0 < N < 13).

Output

The output contains an integer value corresponding to the factorial of N.

Input Sample Output Sample

4 24

Thanks to Cassio F.
URI Online Judge | 1154

Ages
Adapted by Neilor Tonin, URI Brazil

Timelimit: 1

Write an algorithm to read an undeterminated number of data, each containing an individual's age.
The final data, which will not enter in the calculations, contains the value of a negative age. Calculate
and print the average age of this group of individuals.

Input

The input contains an undetermined number of integers. The input will be stop when a negative value
is read.

Output

The output contains a value corresponding to the average age of individuals.

The average should be printed with two digits after the decimal point.

Input Sample Output Sample

34 39.25
56
44
23
-2
Thanks to Cassio F.

URI Online Judge | 1155

S Sequence
Adapted by Neilor Tonin, URI Brazil

Timelimit: 1

Write an algorithm to calculate and write the value of S, S being given by:
S = 1 + 1/2 + 1/3 + + 1/100

Input

There is no input in this problem.

Output

The output contains a value corresponding to the value of S.


The value should be printed with two digits after the decimal point.

Input Sample Output Sample


Thanks to Cassio F.

URI Online Judge | 1156

S Sequence II
Adapted by Neilor Tonin, URI Brazil

Timelimit: 1

Write an algorithm to calculate and write the value of S, S being given by:
S = 1 + 3/2 + 5/4 + 7/8 + ... + 39/?

Input

There is no input in this problem.

Output
The output contains a value corresponding to the value of S.
The value should be printed with two digits after the decimal point.

Input Sample Output Sample

Thanks to Cassio F.

URI Online Judge | 1157

Divisors I
Adapted by Neilor Tonin, URI Brazil

Timelimit: 1

Read an integer N and compute all its divisors.


Input

The input file contains an integer value.

Output

Write all the divisors of N, one value per line.

Input Sample Output Sample

6 1
2
3
6

Thanks to Cassio F.

URI Online Judge | 1158


Sum of Consecutive Odd Numbers III
Adapted by Neilor Tonin, URI Brazil

Timelimit: 1

Read an integer N that is the number of test cases that follows. Each test case contains two
integers X and Y. Print one output line for each test case that is the sum of Y odd numbers
from X including it if is the case. For example:
for the input 4 5, the output must be 45, that is: 5 + 7 + 9 + 11 + 13
for the input 7 4, the output must be 40, that is: 7 + 9 + 11 + 13

Input

The first line of the input is an integer N that is the number of test cases that follow. Each test case is
a line containing two integer X and Y.

Output

Print the sum of all consecutive odd numbers from X.

Input Sample Output Sample

2 21
4 3 24
11 2
URI Online Judge | 1159

Sum of Consecutive Even Numbers


Adapted by Neilor Tonin, URI Brazil

Timelimit: 1

The program must read an integer X indefinite times (stop when X=0). For each X, print the sum of
five consecutive even numbers from X, including it if X is even. If the input number is 4, for example,
the output must be 40, that is the result of the operation: 4+6+8+10+12. If the input number is 11, for
example, the output must be 80, that is the result of 12+14+16+18+20.

Input

The input file contains many integer numbers. The last one is zero.

Output

Print the output according to the example below.

Input Sample Output Sample

4 40
11 80
0
URI Online Judge | 1160

Population Increase
Adapted by Neilor Tonin, URI Brazil

Timelimit: 1

Mariazinha wants to solve an interesting problem. Given the population and growing rate of 2 cities (A
and B), she would like to know how many years would be necessary to the smaller city (always A) to
be greater than the larger city (always B) in population. Of course, she only wants to know the result
for cities that the growing rate for city A is bigger than the growing rate for city B, therefore, she
separated these test cases for you. Your job is to build a program that print the time in years for each
test case.

However, in some cases the time can be so big and Mariazinha don't want to know the exact time for
these cases. In this way, for these test cases, it is enough printing the message "Mais de 1 seculo",
that means "More than a Century".

Input

The first line of the input contains a single integer T, indicating the number of test cases (1 T
3000). Each test case contains four numbers: two integers PA and PB (100 PA 1000000, 100
PB 1000000, PA < PB) indicating respectively the population of A and B and two
numbers G1 and G2 (0.1 G1 10.0, 0.0 G2 10.0, G2 < G1) with one digit after the decimal point
each, indicating the populational growing (in percentual) for A and B respectively.

Pay attention please: The population always is an integer number. So, a growing of 2.5% over a
population of 100 will result in 102 (instead of 102.5) and a growing of 2.5% over a population of 1000
will result in 1025. In addition, use double variables to the growing rate.

Output

Print, for each test case, how many years would be necessary to the city A became greater than the
city B (in inhabitants). Remember that if this time is greater than 100 it will be necessary printing the
message: "Mais de 1 seculo". In each one of these cases, maybe would be interesting interrupt the
counting, otherwise you'll get "Time Limit Exceeded".
Input Sample Output Sample

6 51 anos.
100 150 1.0 0 16 anos.
90000 120000 5.5 3.5 12 anos.
56700 72000 5.2 3.0 Mais de 1 seculo.
123 2000 3.0 2.0 10 anos.
100000 110000 1.5 0.5 100 anos.
62422 484317 3.1 1.0

URI Online Judge | 1164

Perfect Number
Adapted by Neilor Tonin, URI Brazil

Timelimit: 1

In mathematics, a perfect number is an integer for which the sum of all its own positive divisors
(excluding itself) is equal to the number itself. For example the number 6 is perfect, because 1+2+3 is
equal to 6. Your task is to write a program that read integer numbers and print a message informing if
these numbers are perfect or are not perfect.

Input

The input contains several test cases. The first contains the number of test cases N (1 N 100).
Each one of the following N lines contains an integer X (1 X 108), that can be or not a perfect
number.

Output

For each test case print the message X eh perfeito (X is perfect) or X nao eh perfeito (X isn't
perfect) according with to above specification.

Input Sample Output Sample

3 6 eh perfeito
6 5 nao eh perfeito
5
Input Sample Output Sample

28 28 eh perfeito

URI Online Judge | 1165

Prime Number
Adapted by Neilor Tonin, URI Brazil

Timelimit: 1

A Prime Number is a number that is divisible only by 1 (one) and by itself. For example the number 7
is Prime, because it can be divided only by 1 and by 7.

Input

The input contains several test cases. The first contains the number of test cases N (1 N 100).
Each one of the following N lines contains an integer X (1 < X 107), that can be or not a prime
number.

Output

For each test case print the message X eh primo (X is prime) or X nao eh primo (X isn't prime)
according with to above specification.
Input Sample Output Sample

3 8 nao eh primo
8 51 nao eh primo
51 7 eh primo
7

URI Online Judge | 1172

Array Replacement I
Adapted by Neilor Tonin, URI Brazil

Timelimit: 1

Read an array X[10]. After, replace every null or negative number of X by 1. Print all numbers stored in
the array X.

Input

The input contains 10 integer numbers. These numbers can be positive or negative.

Output
For each position of the array, print "X [i] = x", where i is the position of the array and x is the number
stored in that position.

Input Sample Output Sample

0 X[0] = 1
-5 X[1] = 1
63 X[2] = 63
0 X[3] = 1
... ...

Thanks to Cassio F.

URI Online Judge | 1173

Array fill I
Adapted by Neilor Tonin, URI Brazil

Timelimit: 1
Read a number and make a program which puts this number in the first position of an array N[10]. In
each subsequent position, put the double of the previous position. For example, if the input number is
1, the array numbers must be 1,2,4,8, and so on.

Input

The imput contains an integer number V (V < 50).

Output

Print the stored number of each array position, in the form "N[i] = X", where i is the position of the
array and xis the stored number at the position i. The first number for X is V.

Input Sample Output Sample

1 N[0] = 1
N[1] = 2
N[2] = 4
...

Thanks to Cassio F.

URI Online Judge | 1174


Array Selection I
Adapted by Neilor Tonin, URI Brazil

Timelimit: 1

In this problem, your task is to read an array A[100]. At the end, print all array positions that store a
number less or equal to 10 and the number stored in that position.

Input

The input contains 100 numbers. Each number can be integer, floating-point number, positive or
negative.

Output

For each number of the array that is equal to 10 or less, print "A [i] = x", where i is the position of the
array andx is the number stored in the position, with one digit after the decimal point.

Input Sample Output Sample

0 A[0] = 0.0
-5 A[1] = -5.0
63 A[3] = -8.5
-8.5 ...
...

Thanks to Cassio F.
URI Online Judge | 1175

Array change I
Adapted by Neilor Tonin, URI Brazil

Timelimit: 1

Write a program that reads an array N [20]. After, change the first element by the last, the second
element by the last but one, etc.., Up to change the 10th to the 11th. print the modified array.

Input

The input contains 20 integer numbers, positive or negative.

Output

For each position of the array N print "N[i] = Y", where i is the array position and Y is the number
stored in that position.

Input Sample Output Sample

0 N[0] = 230
-5 N[1] = 63
... ...
63 N[18] = -5
230 N[19] = 0

Thanks to Cassio F.
URI Online Judge | 1176

Fibonacci Array
Adapted by Neilor Tonin, URI Brazil

Timelimit: 1

Write a program that reads a number and print the Fibonacci number corresponding to this read
number. Remember that the first elements of the Fibonacci series are 0 and 1 and each next term is
the sum of the two preceding it. All the Fibonacci numbers calculated in this program must fit in a
unsigned 64 bits number.

Input

The first line of the input contains a single integer T, indicating the number of test cases. Each test
case contains a single integer N (0 N 60), corresponding to the N-th term of the Fibonacci series.

Output

For each test case in the input, print the message "Fib(N) = X", where X is the N-th term of the
Fibonacci series.

Input Sample Output Sample

3 Fib(0) = 0
0 Fib(4) = 3
4 Fib(2) = 1
2

Thanks to Cassio F.
URI Online Judge | 1177

Array Fill II
Adapted by Neilor Tonin, URI Brazil

Timelimit: 1

Write a program that reads a number T and fill a vector N[1000] with the numbers from 0 to T-1
repeated times, like as the example below.

Input

The input contains an integer number T (2 T 50).

Output

For each position of the array N, print "N[i] = x", where i is the array position and x is the number
stored in that position.

Input Sample Output Sample

3 N[0] = 0
N[1] = 1
N[2] = 2
Input Sample Output Sample

N[3] = 0
N[4] = 1
N[5] = 2
N[6] = 0
N[7] = 1
N[8] = 2
...

Thanks to Cassio F.

URI Online Judge | 1178

Array Fill III


Adapted by Neilor Tonin, URI Brazil

Timelimit: 1

Read a number X. Put this X at the first position of an array N [100]. In each subsequent position (1 up
to 99) put half of the number inserted at the previous position, according to the example below. Print
all the vector N.

Input

The input contains a double precision number with four decimal places.
Output

For each position of the array N print "N[i] = Y", where i is the array position and Y is the number
stored in that position. Each number of N[...] must be printed with 4 digits after the decimal point.

Input Sample Output Sample

200.0000 N[0] = 200.0000


N[1] = 100.0000
N[2] = 50.0000
N[3] = 25.0000
N[4] = 12.5000
...

URI Online Judge | 1179

Array Fill IV
Adapted by Neilor Tonin, URI Brazil

Timelimit: 1

In this problem you need to read 15 numbers and must put them into two different arrays: par if the
number is even or impar if this number is odd. But the size of each of the two arrrays is only 5
positions. So every time you fill one of two arrays, you must print the entire array to be able to use it
again for the next numbers that are read. At the end, all remaining numbers of each one of these two
arrays must be printed beggining with the odd array. Each array can be filled how many times are
necessary.

Input

The input contains 15 integer numbers.

Output

Print the output like the following example.

Input Sample Output Sample

1 par[0] = 4
3 par[1] = -4
4 par[2] = 2
-4 par[3] = 8
2 par[4] = 2
3 impar[0] = 1
8 impar[1] = 3
2 impar[2] = 3
5 impar[3] = 5
-7 impar[4] = -7
54 impar[0] = 789
76 impar[1] = 23
789 par[0] = 54
23 par[1] = 76
98 par[2] = 98

URI Online Judge | 1180

Lowest Number and Position


Adapted by Neilor Tonin, URI Brazil

Timelimit: 1

Write a program that reads a number N. This N is the size of a array X[N]. Next, read each of the
numbers of X, find the smallest element of this array and its position within the array, printing this
information.

Input

The first line of input contains one integer N (1 < N <1000), indicating the number of elements that
should be read to an array X[N] of integer numbers. The second row contains each of the N values,
separated by a space.

Output

The first line displays the message Menor valor: followed by a space and the lowest number read in
the input. The second line displays the message Posicao: followed by a space and the array position
in which the lowest number is, remembering that the array starts at the zero position.

Input Sample Output Sample

10 Menor valor: -5
1 2 3 4 -5 6 7 8 9 10 Posicao: 4
URI Online Judge | 1181

Line in Array
By Neilor Tonin, URI Brazil

Timelimit: 1

Your job in this problem is to read a number that is a line of an array, an uppercase character,
indicating the operation to be performed and all elements of a bidimentional array M[12][12]. Then,
you have to calculate and print the sum or average of all elements within the green area according to
the case. The following figure illustrates the case when is entered the number 2 to the array line,
showing all elements that must be considered in the operation.

Input

The first line of the input contains a simple integer L (0 L 11) indicating the line to be considered in
the operation. The second line of the input contains a single uppercase character T ('S' or 'M'),
indicating the operation Sum or Average (Mdia in portuguese) to be performed with the elements of
the array. Follow the 144 floating-point numbers of the array, considering that the elements are
inserted line by line, from line 0 to line 11, always from left to right.

Output

Print the calculated result (sum or average), with one digit after the decimal point.
Input Sample Output Sample

2 12.6
S
1.0
-3.5
2.5
4.1
...

URI Online Judge | 1182

Column in Array
By Neilor Tonin, URI Brazil

Timelimit: 1

Your job in this problem is to read a number that is a column of an array where an operation will be
performed, an uppercase character, indicating the operation to be performed and all elements of a
bidimentional arrayM[12][12]. Then, you have to calculate and print the sum or average of all elements
within the green area according to the case. The following figure illustrates the case when is entered
the number 5 to the array column, showing all elements that must be considered in the operation.

Input

The first line of the input contains a simple integer C (0 C 11) indicating the column to be
considered in the operation. The second line of the input contains a single uppercase character T ('S'
or 'M'), indicating the operation Sum or Average (Mdia in portuguese) to be performed with the
elements of the array. Follow 144 floating-point numbers of the array.

Output

Print the calculated result (sum or average), with one digit after the decimal point.

Input Sample Output Sample

5 12.6
S
1.0
-3.5
2.5
4.1
...

URI Online Judge | 1183

Above the Main Diagonal


By Neilor Tonin, URI Brazil

Timelimit: 1

Read an uppercase character that indicates an operation that will be performed in an array M[12][12].
Then, calculate and print the sum or average considering only that numbers that are above the main
diagonal of the array, like shown in the following figure (green area).
Input

The first line of the input contains a single uppercase character O ('S' or 'M'), indicating the operation
Sum or Average (Mdia in portuguese) to be performed with the elements of the array. Follow 144
floating-point numbers of the array.

Output

Print the calculated result (sum or average), with one digit after the decimal point.

Input Sample Output Sample

S 12.6
5.0
0.0
-3.5
2.5
4.1
...

URI Online Judge | 1184

Below the Main Diagonal


By Neilor Tonin, URI Brazil
Timelimit: 1

Read an uppercase character that indicates an operation that will be performed in an array M[12][12].
Then, calculate and print the sum or average considering only that numbers that are below of the
main diagonal of the array, like shown in the following figure (green area).

Input

The first line of the input contains a single uppercase character O ('S' or 'M'), indicating the operation
Sum or Average (Mdia in portuguese) to be performed with the elements of the array. Follow 144
floating-point numbers of the array.

Output

Print the calculated result (sum or average), with one digit after the decimal point.

Input Sample Output Sample

S 12.6
5.0
0.0
-3.5
2.5
4.1
...
URI Online Judge | 1185

Above the Secundary Diagonal


By Neilor Tonin, URI Brazil

Timelimit: 1

Read an uppercase character that indicates an operation that will be performed in an array M[12][12].
Then, calculate and print the sum or average considering only that numbers that are above the
secundary diagonal of the array, like shown in the following figure (green area).

Input

The first line of the input contains a single uppercase character O ('S' or 'M'), indicating the operation
Sum or Average (Mdia in portuguese) to be performed with the elements of the array. Follow 144
floating-point numbers of the array.

Output

Print the calculated result (sum or average), with one digit after the decimal point.

Input Sample Output Sample

S 12.6
5.0
0.0
-3.5
Input Sample Output Sample

2.5
4.1
...

URI Online Judge | 1186

Below the Secundary Diagonal


By Neilor Tonin, URI Brazil

Timelimit: 1

Read an uppercase character that indicates an operation that will be performed in an array M[12][12].
Then, calculate and print the sum or average considering only that numbers that are below of the
Secundary diagonal of the array, like shown in the following figure (green area).

Input

The first line of the input contains a single uppercase character O ('S' or 'M'), indicating the operation
Sum or Average (Mdia in portuguese) to be performed with the elements of the array. Follow 144
floating-point numbers of the array.
Output

Print the calculated result (sum or average), with one digit after the decimal point.

Input Sample Output Sample

S 12.6
5.0
0.0
-3.5
2.5
4.1
...

URI Online Judge | 1187

Top Area
By Neilor Tonin, URI Brazil

Timelimit: 1

Read an uppercase character that indicates an operation that will be performed in an array M[12][12].
Then, calculate and print the sum or average considering only that numbers that are included in the
green area of this array, like shown in the following figure.
Input

The first line of the input contains a single uppercase character O ('S' or 'M'), indicating the operation
Sum or Average (Mdia in portuguese) to be performed with the elements of the array. Follow 144
double numbers of the array.

Output

Print the calculated result (sum or average), with one digit after the decimal point.

Input Sample Output Sample

S 126.2
5.0
130.0
-3.5
2.5
4.1
...

URI Online Judge | 1188

Inferior Area
By Neilor Tonin, URI Brazil
Timelimit: 1

Read an uppercase character that indicates an operation that will be performed in an array M[12][12].
Then, calculate and print the sum or average considering only that numbers that are included in the
green area of this array, like shown in the following figure.

Input

The first line of the input contains a single uppercase character O ('S' or 'M'), indicating the operation
Sum or Average (Mdia in portuguese) to be performed with the elements of the array. Follow 144
floating-point numbers (double) of the array.

Output

Print the calculated result (sum or average), with one digit after the decimal point.

Input Sample Output Sample

S 126.2
5.0
130.0
-3.5
2.5
4.1
...
URI Online Judge | 1189

Left Area
By Neilor Tonin, URI Brazil

Timelimit: 1

Read an uppercase character that indicates an operation that will be performed in an array M[12][12].
Then, calculate and print the sum or average considering only that numbers that are included in the
green area of this array, like shown in the following figure.

Input

The first line of the input contains a single uppercase character O ('S' or 'M'), indicating the operation
Sum or Average (Mdia in portuguese) to be performed with the elements of the array. Follow 144
floating-point numbers of the array.

Output

Print the calculated result (sum or average), with one digit after the decimal point.

Input Sample Output Sample

S 122.2
5.0
130.0
-3.5
Input Sample Output Sample

2.5
4.1
...

URI Online Judge | 1190

Right Area
By Neilor Tonin, URI Brazil

Timelimit: 1

Read an uppercase character that indicates an operation that will be performed in an array M[12][12].
Then, calculate and print the sum or average considering only that numbers that are included in the
right area (green area) of this array, like shown in the following figure.

Input

The first line of the input contains a single uppercase character O ('S' or 'M'), indicating the operation
Sum or Average (Mdia in portuguese) to be performed with the elements of the array. Follow 144
floating-point numbers of the array.
Output

Print the calculated result (sum or average), with one digit after the decimal point.

Input Sample Output Sample

S 122.2
5.0
130.0
-3.5
2.5
4.1
...

URI Online Judge | 1435

Square Matrix I
Adapted by Josu P. de Castro Brazil

Timelimit: 2

Write a program that read an integer number N (0 N 100) that correspont to the order of a
Bidimentional array of integers, and build the Array according to the above example.

Input

The input consists of several integers numbers, one per line, corresponding to orders from arrays to
be built. The end of input is indicated by zero (0).

Output

For each integer number of input, print the corresponding array according to the example. (the values
of the arrays must be formatted in a field of size 3 right justified and separated by a space. None
space must be printed after the last character of each row of the array. A blank line must be printed
after each array.
Sample Input Sample Output

1 1
2
3 1 1
4 1 1
5
0 1 1 1
1 2 1
1 1 1

1 1 1 1
1 2 2 1
1 2 2 1
1 1 1 1

1 1 1 1 1
1 2 2 2 1
1 2 3 2 1
1 2 2 2 1
1 1 1 1 1

URI Online Judge | 1478

Square Matrix II
By Josu Pereira de Castro, Unioeste Brazil

Timelimit: 1

Write a program that read an integer number N (0 N 100) that correspont to the order of a
Bidimentional array of integers, and build the Array according to the above example.

Input

The input consists of several integers numbers, one per line, corresponding to orders from arrays to
be built. The end of input is indicated by zero (0).
Output

For each integer number of input, print the corresponding array according to the example. (the values
of the arrays must be formatted in a field of size 3 right justified and separated by a space. None
space must be printed after the last character of each row of the array. A blank line must be printed
after each array.

Sample Input Sample Output

1 1
2
3 1 2
4 2 1
5
0 1 2 3
2 1 2
3 2 1

1 2 3 4
2 1 2 3
3 2 1 2
4 3 2 1

1 2 3 4 5
2 1 2 3 4
3 2 1 2 3
4 3 2 1 2
5 4 3 2 1

URI Online Judge | 1534

Array 123
Adapted by Neilor Tonin, URI Brazil

Timelimit: 1

Read an integer N that is the size of a bidimentional array that must be printed like the given example.
Input

The input contains many test cases and ends with EOF. Each test case consist in a integer
number N (3 N < 70), that indicates the size (lines and columns) of a bidimentional array that must
be printed.

Output

For each N read, print the output according to the given example.

Sample Input Sample Output

4 1332

7 3123

3213

2331

1333332

3133323

3313233

3332333

3323133

3233313

2333331
URI Online Judge | 1541

Building Houses
By Normandes Jr, UFU Brazil

Timelimit: 1

Mr Pi is a famous constructor of Codingland. He needs your help to find out the best lands in the city
to his projects.

For instance, he has a project to build a house of 8 meters for 10 meters but, the city laws only allow
build houses in this neighborhood, in maximum 20% of total area. All lands in this city are perfectly
square. For your information the house side is showed only for you to know the house's area that will
be built. (E.g: For a house with 1 meters by 10 meters, in a neighborhood that allows house use 100%
of the land, Mr Pi would needed a land with 10 square meters. The land side in this case, should be
3.163 meters, that truncated it is 3). Help Mr Pi find out the ideal land for each project.

Input

The input has many test cases. Each one is made by three integer numbers A, B and C (> 0 and <=
1000) separated by one blank space. This numbers are the size of the house (A and B) and the
maximum percentage allowed to build in this neighborhood (C). An unique 0 (zero) value means end
of inputs.

Output

Should be printed an integer number, that is the size of the land. This value should be truncated.

Sample Input Sample Output

8 10 20 20
1 10 100 3
10 3 100 5
0

Contest Algar Telecom XIII


URI Online Judge | 1557

Square Matrix III


By Gabriel Dalalio, ITA Brazil

Timelimit: 1

Write a program that read an integer number N (0 N 15) that correspont to the order of a
bidimentional array of integers, and build the array according to the above example.

Input

The input consists of several integers numbers, one per line, corresponding to orders from arrays to
be built. The end of input is indicated by zero (0).

Output

For each integer number of input, print the corresponding array according to the example. The values
of the array must be formatted in a field of size T right justified and separated by a space, where T is
equal to the number of digits of the biggest number in the array. None space must be printed after the
last character of each row of the array. A blank line must be printed after each array.

Sample Input Sample Output

1 1

2 1 2
2 4
3
1 2 4
Sample Input Sample Output

4 2 4 8
4 8 16
5
1 2 4 8
0 2 4 8 16
4 8 16 32
8 16 32 64

1 2 4 8 16
2 4 8 16 32
4 8 16 32 64
8 16 32 64 128
16 32 64 128 256

Contest Dalalio 2014

URI Online Judge | 1564

Brazil World Cup


By Gabriel Dalalio, ITA Brazil

Timelimit: 1

Brazil is the country hosting the world cup this year. However, there are many people protesting
against the government. In social networks you can see people saying the world cup will not happen.

But these rumors that there will be no world cup are totally false, president Dilma Rousseff has
warned: the world cup will happen, and if someone complains about it, we will host again!

Input

The input contains several test cases and ends with EOF. Each test case consists of a line containing
a number N of complaints about the world cup forwarded to the president (0 N 100).
Output

For each test, the output consists of one line saying "vai ter copa!" if there is no complaints for
president. If there are complaints, the output should say "vai ter duas!".

Sample Input Sample Output

0 vai ter copa!

1 vai ter duas!

0 vai ter copa!

2 vai ter duas!

100 vai ter duas!

0 vai ter copa!

Contest Dalalio 2014

URI Online Judge | 1589

Bob Conduit
By Bruno Adami, Universidade de So Paulo - So Carlos Brazil

Timelimit: 1
You have got two circular energy cables. The first one has radius R1 and the second R2. You need to
buy a circular conduit (see the image below) that fits those two cables:

What is the smallest radius of a conduit you need to buy? In other words, given two circles, what is the
smallest radius of a third circle that circumscribe the other two?

Input

In the first line there is an integer T (T 10000), indicating the number of test cases.

On the only line of each test case we will have the two integers R1 and R2 indicating the cables
radius. The integers will be positive and all the math will fit in a regular integer of 32 bits.

Output

In each test case, output the answer in a single line.

Sample Input Sample Output

3 2

1 1 10

2 8 10

8 2

Contest Seletiva USP So Carlos 2014


URI Online Judge | 1759

Ho Ho Ho
By Lucas Campesatto, URI Online Judge Brazil

Timelimit: 1

Santa Claus is playing with his elves to entertain them during the Christmas Eve. The game consists
of the elves writing numbers on pieces of paper and place on the cap of Santa Claus. After all finished
to put the numbers, Santa draws a number and that number is how many "Ho" he should say.

Your job is to help Santa Claus by making a problem that shows all the "Ho" that he should speak
given the number drawn.

Input

The input consists of a single integer N (0 < N 106) representing how many "Ho" will be spoken by
Santa.

Output

The output consists of all "Ho" that Santa should speak separated by a space. After the last "Ho" you
must present an "!" ending the program.

Input Sample Output Sample

5 Ho Ho Ho Ho Ho!

Contest de Natal 2014


URI Online Judge | 1789

The Race of Slugs


By Thalyson Nepomuceno, UECE Brazil

Timelimit: 1

The slugs racing is a sport that has grown in recent years, causing several people dedicate their lives
trying to capture fast slugs, and trains them to make millions in races around the world. But the task of
capturing fast slugs is not an easy task, since almost all the slugs are very slow. Each slug is
classified at a level depending on their speed:

Level 1: If speed is less than 10 cm/h.


Level 2: If speed is greater than or equal to 10 cm/h and lower than 20 cm/h.
Level 3: If speed is greater than or equal to 20 cm/h.

Your task is to identify which level of speed faster slug of a group of slugs.

Input

The entry consists consists multiple test cases, and each consists of two lines: The first line contains
an integerL (1 L 500) representing the number of slugs of the group, and the second line
contains L integers Vi (1 Vi 50) representing the speeds of each slug.
The input ends with end of file (EOF).

Output

For each test case, output a single line with the level of speed faster slug of a group of slugs.
Input Sample Output Sample

10 3
10 10 10 10 15 18 20 15 11 10 1
10 2
1 5 2 9 5 5 8 4 4 3
10
19 9 1 4 5 8 6 11 9 7

Olimpada Cearense de Informtica - 2014

URI Online Judge | 1827

Square Array IV
By Neilor Tonin, URI Brazil

Timelimit: 1

Your work in this program is to read an integer number that is the size of a square matrix (width and
height) to be filled as follows: the outer part is filled with 0 in the inner part is filled with 1, the main
diagonal is filled with 2, the secondary diagonal is filled with 3 and the central element is 4, as the
examples below.

Obs: square with '1' always starts at position size / 3, considering width and height and both begin in 0
(zero).

Input

The input contains a number of test cases and ends with EOF (end of file). Each test case consists of
an odd integer number N (5 N 101) that is the size of the array. For each test case, print the
corresponding array as below. After each test case, print a blank line.
Output

For each test case, print the corresponding array as below. After each test case, print a blank line.

Input Sample Output Sample

5 20003
11 01110
01410
01110
30002

20000000003
02000000030
00200000300
00011111000
00011111000
00011411000
00011111000
00011111000
00300000200
03000000020
30000000002

URI Online Judge | 1828

Bazinga
In the 8th episode of Big Bang Theory's second season, The Lizard-Spock Expansion, Sheldon and
Raj are arguing about what is the best: the movie Saturn 3 or the TV show Deep Space 9. Raj
suggests rock-paper-scissors to settle down the dispute. However, Sheldon says "Ooh, I don't think
so. No, anectodal evidence suggests that in the game of rock-paper-scissors, players familiar with
each other will tie 75 to 80% of the time due to the limited number of outcomes. I suggest rock-paper-
scissors-lizard-Spock".

The rules of the game are:

1. scissors cuts paper;

2. paper covers rock;


3. rock crushes lizard;

4. lizard poisons Spock;

5. Spock smashes scissors;

6. scissors decapitates lizard;

7. lizard eats paper;

8. paper disproves Spock;

9. Spock vaporizes rock;

10. rock crushes scissors.

Both choosed Spock and the game tied. However, it isn't hard to realize what would happened if the
game had continued. In the case of Sheldon's victory, he would've said: "Bazinga!"; if Raj had won,
Sheldon would declare: "Raj trapaceou!" ("Raj cheated" in portuguese); in ties, he would request a
new game: "De novo!" ("Again!", in portuguese). Given the options chosen by both, make a program
that prints Sheldon reaction to the outcome.

Input
The first line contains an integer T (T 100) indicating the number of test cases. Each test case is
described using one line. The line contains Sheldon and Raj options, separated by one blank space.
The possible options are: pedra, papel, tesoura, lagarto e Spock (rock, paper, scissors, lizard and
Spock).

Output
For each test case your program must output a single line with the following message: "Caso #t: R",
where t is the test case number and R is Sheldon's reaction to the outcome: "Bazinga!", "Raj
trapaceou!", or "De novo!".

Input Samples Output Samples

3 Caso #1: Bazinga!


papel pedra Caso #2: Raj trapaceou!
lagarto tesoura Caso #3: De novo!
Spock Spock
URI Online Judge | 1837

Preface
By Leandro Zatesko, UFFS Brazil
Timelimit: 1

It has begun the IV UFFS Programming Contest! We hope you enjoy the next hours you are going to
spend with us, as we hope you have a lot of fun! Good luck!

This is the 3rd year of the Programming Club, an extension program whose primary goal is to help the
programmers of the Brazilian region known as Southern Border to get readier to face the
computational challenges from both academic and corporate worlds. Our main strategy lies in
promoting workshops and training sessions for Programming contests, not only for students of our
institution (UFFS), but also for whoever wants to participate. Despite of many issues, we find
ourselves very happy with the results we have been achieving. Having other institutions as partners,
as UNOCHAPEC, URI and UNOESC, we collaborated to make Chapec in the past two years the
2nd largest site of ICPC Brazilian Subregional Contest, which is another indicator of the enthusiasm our
people has in Programming.

In order to warm you up for this particular contest, we shall ask you to write a program which
calculates the quotient and the remainder of the division of two integers, can that be? Recall that the
quotient and the remainder of the division of an integer a by a non-zero integer b are respectively the
only integers q and r such that 0 r < |b| and:

a=bq+r

In case you don't know it, the theorem that guarantees the existence and the uniqueness of the
integers q and ris known as Euclidean Division Theorem or Division Algorithm.

Input

The input consists of two integers a and b (-1,000 a, b < 1,000).

Output

Print the quotient q followed by the remainder r of the division of a by b.

Input Samples Output Samples

7 3 2 1

7 -3 -2 1

-7 3 -3 2

4 Maratona UFFS
URI Online Judge | 1847

Welcome to the Winter!


By Leandro Zatesko, UFFS Brazil
Timelimit: 1

Welcome to the Erechim Winter School of the ICPC Brazilian Subregional Contest! We sincerely hope
you learn a lot during these days so you can be very successful in the Programming contests yet to
come, but above all we hope you enjoy the School, for when we have fun and enjoy ourselves
studying and programming, the training stops being a burden and becomes a hobby. So, have fun!

The winter is a wonderful season, is it not? We all love wearing a poncho, joining a chimarro circle,
baking pinhesin a wooden burning stove But not everyone likes the winter, especially in places
where winter uses to be very cruel. In Westeros, for example, the people's humour is defined
according to climate tendencies. Based on the temperatures of the last three days, the people can be
sad or happy, being more likely to make war or to make love, respectively. And, let us be honest, it is
precisely because of the scenes of love and war that we love Game of Thrones!

If the temperature decreased from the 1 st to the 2nd day, but increased or remained constant
from the 2nd to the 3rd, the people are happy (first figure).

If the temperature increased from the 1 st to the 2nd day, but decreased or remained constant
from the 2nd to the 3rd, the people are sad (second figure).

If the temperature increased from the 1 st to the 2nd day and from the 2nd to the 3rd, but increased
from the 2nd to the 3rd less than what had increased from the 1 st to the 2nd, the people are sad
(third figure).

If the temperature increased from the 1 st to the 2nd day and from the 2nd to the 3rd, but increased
from the 2nd to the 3rd at least what had increased from the 1 st to the 2nd, the people are happy
(fourth figure).

If the temperature decreased from the 1 st to the 2nd day and from the 2nd to the 3rd, but
decreased from the 2nd to the 3rd less than what had decreased from the 1 st to the 2nd, the
people are happy (fifth figure).

If the temperature decreased from the 1 st to the 2nd day and from the 2nd to the 3rd, but
decreased from the 2nd to the 3rd at least what had decreased from the 1st to the 2nd, the people
are sad (sixth figure).

If the temperature remained constant from the 1 st to the 2nd day, the people are happy if the
temperature increased from the 2nd to the 3rd or sad otherwise (respectively, seventh and eighth
figures).
Input
The input consists only of three integers, A, B e C (-100 A, B, C 100), which represent
respectively the temperatures recorded in the 1st, in the 2nd and in the 3rd day.

Output
Print a line containing a happy or a sad smiley, representing how is the humour of the people of
Westeros according to the climate tendencies.

Input Samples Output Samples

20 10 12 :)
10 20 18 :(
4 16 20 :(
4 10 20 :)
20 10 6 :)
20 16 4 :(
10 10 14 :)
10 10 2 :(

URI Online Judge | 1848


Counting Crow
By Emilio Wuerges, UFFS Brazil

Timelimit: 1

As we know, there's a three-eyed crow. What it isn't well known is that the three-eyed crow can
foresaw the results of Westeros lottery. Meanwhile every other crow is flying collecting entries for the
lottery, the three-eyed crow already knows the results, and when Bran dreams with the three-eyed
crow, the crow tells him the result. Bran always remember these dreams very well, however, he can't
understand them fast enough to know the result. Your task is write a program to calculate the result
from Bran's dream.

During the dream, the crow blinks many times and screams exactly 3 times. Every scream
corresponds to a result.

Every blink of the crow communicates a binary number. An open eye means 1 and a closed eye
means 0. The left eye is the most significative eye and the right eye is the least significative eye.
Every blink this number is added and when the crow screams, the sum is a result.

Input

The input describes, in every line, in order, a scream or a blink of the crow.

A scream is represented by the string caw caw.

A blink is formed by three characters * ou -, representing, respectively, an open eye or a closed eye,
from left to right.

Remember that the crow has 3 eyes.

The winning numbers at lottery do not exceed 1000.

Output

The output are 3 lines, each one with one result of the lottery.

Input Sample Output Sample

--* 1
caw caw 4
*-- 0
caw caw
caw caw
Input Sample Output Sample

--* 3
--* 8
--* 5
caw caw
*--
*--
caw caw
--*
*--
caw caw

Escola de Inverno da Maratona - Erechim RS - 2015


URI Online Judge | 1855

Maester's Map
By Emilio Wuerges, UFFS Brazil
Timelimit: 1

Sam found a big bunch of maps from old Maester Aemon, which at a first look, should point, each
one, a location of a chest full of obsidian. However, after taking a better look, some maps had obvious
errors, while others, only sending a team of explorers to know.

What is known is that some maps point to an absurd location outside of the map and some end up in
circles, ending up to be completely useless.

Since the maps are many, the brothers of the Nights Watch are few and winter is comming, your work
is to write a program to check if a map leads or not to a chest with obsidian.

Maps have these features:

The starting point is always at the top left corner.

The maps are rectangular and each point of the map has one of these symbols:

o A traversable terrain space.

o An arrow, representing a possible change of direction.

o A chest.

Since the places these maps describe are very dangerous, it is vital that the path described in the
map is strictly followed.

Input
The first line contains a positive integer x < 100 with the width of the map.

The second line contains a positive integer y < 100 with the height of the map.

The following lines contain various characters within the map's dimensions.
The valid characters are:

An arrow to the right: >

An arrow to the left: <

An arrow ponting down: v

An arrow pointing up: ^

A space of traversable terrain: .

A chest: *
Output
The output must consist of a single line containing a single character ! or *.

! means that the map is invalid. * means that the map is valid.

Input Samples Output Samples

6 *
1
>....*
7 !
5
>.....v
.......
.......
.......
^.....<
Escola de Inverno da Maratona - Erechim RS - 2015
URI Online Judge | 1858

Theon's Answer
By Ricardo Oliveira, UFPR Brazil

Timelimit: 1

Ramsay: "(...) you win the game if you figure out who I am and why I'm torturing you."

Theon must think quickly and guess who his torturer is! However, Ramsey already decided what he
will do after Theon gives his answer.

There are N people Theon may say the torturer is. Let us consider that the people are numbered from
1 to N. If Theon answers the torturer is person i, Ramsay will hit him Ti times.

You task is to help Theon and determine what he should answer in order to minimize the number of
times he will be hit.

Input

The first line contains an integer N (1 N 100). The second line contains N integers T1, T2, ..., TN (0
Ti 20).

Output

Print a single line containing the number of the person Theon must say the torturer is. If there is more
than one possible answer, print the smallest one.

Input Samples Output Samples

3 2
8 0 7

2 1
1 1

Escola de Inverno da Maratona - Erechim RS - 2015


URI Online Judge | 1864

Our Days Are Never Coming Back


By Leandro Zatesko, UFFS Brazil

Timelimit: 1

So, have you liked the Winter School this year? In order to make this School happen, many have
worked, whether in writing the problems, in configuring the Portal, in making the arrengements for the
event or in raising the funds. Our special acknowledgement this year goes to Professor Ricardo
Oliveira, who has not only accepted our invitation to come and teach the workshops but has also been
participating on the organisation of this School. We are sure that his experience and his career at
ICPC as contestant and as coach have motived and inspired us all.

We hope you have enjoyed these last days in Essos and in Westeros, we hope you have learned a lot
and had fun.But it is not only in Essos and in Westeros that you should have fun. Here, in Beyond the
Wall, programming is also fun. Keep studying, keep training, and more and more. What is important is
the path you choose to pursue from now on. Our advice is that you should always enjoy every single
moment, every workshop, every school, every training session, every time practicing or studying at
home. Our days are never coming back.

Input

The input consists of a single integer N (1 N 34) in a line.

Output

Print the N first characters of Sren Kierkegaard's quote defined by the letters underlined in this
problem statement. Be careful, for no blank space has been underlined you are supposed to guess
the number and the location of the blank spaces at the sentence. The only line of output shall consist
only of capital letters and blank spaces, and shall be ended by end-of-line.
Input Samples Output Samples

1 L

3 LIF

7 LIFE IS

Escola de Inverno da Maratona - Erechim RS - 2015

URI Online Judge | 1865

Mjlnir
By Ricardo Martins, IFSULDEMINAS Brazil

Timelimit: 1

Odin created to Thor the most faithful and powerful possible weapon, Mjolnir hammer. Made of a
special mystical ore called Uru and forged in the heart of a star by blacksmiths Gods of Asgard , Brokk
and Eitri , blacksmiths legendary.

One day , Thor challenged his friends to see who could raise the Mjlnir .

Write a program that , given a name , and the force in Newtons applied to try to lift the Thunder
Hammer , inform the person succeeded in lifting it .

Input
An integer C shall be informed , which is the amount of test cases. Each test case begins with one
word , which is the first name of who is trying to raise Mjlnir , and an integer N ( 1 N 25000 ),
indicating the force applied upward in Newtons to pull the hammer of so try to lift it.

Output

For each test case print a 'Y' character , if the person has managed to raise or 'N' if you have not
achieved .

Input Sample Output Sample

4 N

Hulk 5000 N

Tony 1000 Y

Thor 50 N

Steve 500

V Olimpada Interna de Programao do IFSULDEMINAS - OLIP 2015

URI Online Judge | 1866

Bill
By Ricardo Martins, IFSULDEMINAS Brazil
Timelimit: 1

Two friends ask the attendant a snack bar propose a challenge , so that whoever hit him more , would
not pay the bill. Then the following is proposed : Given the following sum below report the result , with
the same number of terms : S = 1 - 1 + 1 - 1 + 1 - 1 + 1 - 1 ... Write a program that , given a number of
terms, report the result of the sum above.

Input

An integer C shall be informed , which is the amount of test cases. Each test case starts with an
integer N ( 1 N 1000) , indicating the number of terms of the sum .

Output

For each test case print a number S , which is the sum of N terms of expression.

Input Sample Output Sample

3 1

11 1

7 0

18

V Olimpada Interna de Programao do IFSULDEMINAS - OLIP 2015


URI Online Judge | 1914

Whose Turn Is It?


By Jadson Jos Monteiro Oliveira, Faculdade de Balsas Brazil

Timelimit: 1

Hopscotch is probably the game where townhouse's children more have fun, however the game has
caused a good time for discussion and crying in children who practice it. The cause of the disorder is
to decide who will be the next to jump, but recently Quico (The Genius!) had a great idea for to solve
the problem. Basically the game can only to be played every two players in one turn and to choose
the next player Quico indicated to use the traditional method even or odd, where both players report
one number and if the sum these numbers is even, the player that choose PAR win or vice verse.
However the use that method has left the Quico crazy, crazy, crazy... And for that reason he asked for
your help, asked you a program that given the name of the players, their respective choices (PAR or
IMPAR) and the numbers, tell who was the winner.

Input

The first line of input contains a single integer QT (1 QT 100), indicating the number of following
test cases. Each test case contains two lines. In first line will be told the name of the player 1 followed
by his choice, PAR or IMPAR, and after the name of the player 2 followed by his choice, PAR or
IMPAR. In second line of test case, contains two integer number N (1 N 10) and M (1 M
10), representing respectively the numbers chosen by players 1 and player 2. It it garanteed that
player 1 choice's (PAR or IMPAR) will be differ from choice of player 2 (PAR or IMPAR) and that the
name of the players consist only of letters and will not exceed 100 characters.

Output

For each test case, print a single line containing the name of winner player.

Input Sample Output Sample

4 Quico

Quico PAR Chiquinha IMPAR Marcus

9 7 Conrado
Input Sample Output Sample

Dami PAR Marcus IMPAR Chaves

12 3

Dayran PAR Conrado IMPAR

3 1000000000

Popis PAR Chaves IMPAR

2 7

Codando na Vila - 2015

URI Online Judge | 1921

Guilherme and His Kites


By Gustavo Ribeiro, IFPB - Campina Grande Brazil

Timelimit: 1

Guilherme loves kites, kites of different colors, forms and sizes. He realized that in order to kites
become stable, and thus fly higher, they must have a taut string connecting all pairs of non-neighboors
tips.

Despite being a very creative and clever child, Guilherme doesnt know how to determine the number
of strings necessary to make a kite of n sides stable. Could you help him?

Input

The single line of the input contains an integer 3 n 105, the number of sides of the kite.
Output

Print a single number, the number of strings that Guilherme needs to make a kite of n sides stable.

Input Samples Output Samples

4 2

10 35

11 44

Tribute to my brother Guilherme, he loves kites.


Tapioca's Round I, 2015

URI Online Judge | 1924

Vitria and Her Indecision


By Gustavo Ribeiro, IFPB - Campina Grande Brazil

Timelimit: 1
Theres no one in the world more indecisive than Vitria. Despite the fact that she knows shes a great
programmer, like one of the that have a lot of projects in IT field published and many others being
written, shes not sure if shes going to be a professional programmer. There are nights that she wants
to study Computer Science (Cincia da Computao, in portuguese), there are days she wants to
study some Engineering, some days she even talks about taking some Humanities course, what a sin!
But you can help her do the right choice. Your task is simple, Itll be given a list with the bachelor
courses that Vitria is in doubt, the output should be the course she must choose.

Input

The first line of the input is an integer 1 n 2000, representing the number of courses that must be
considered. Each of the next n lines, there is a course S, 1 |S| 100, the name of one of the
courses Vitria is in the doubt.

Output

Print the name of the course Vitria must take in portuguese without accentuation.

Input Samples Output Samples

3 Ciencia da Computacao

Ciencia da Computacao

Engenharia Eletrica

Matematica

3 Ciencia da Computacao

Sociologia

Filosofia

Fisica

Tribute to Vitria.
Tapioca's Round I, 2015
URI Online Judge | 1929

Triangle
By Guilherme Albuquerque Pinto, Universidade Federal de Juiz de Fora Brazil

Timelimit: 1

Ana and her friends are making a geometry work to school, they need to create various triangles on a
chart, with a few sticks of different lengths. Soon they realized that you can not form triangles with
three rods of any lengths: if one of the rods is too large relative to the other two, you can't form a
triangle.

In this issue, you have to help Ana and her friends to determine if, given the lengths of four rods, it is
or not possible to select three rods, among the four, and form a triangle.

Input

The entry consists of one line containing four integers A, B, C and D (1 A, B, C, D 100).

Output

Your program should only produce a line containing only one character, which must be 'S' if it is
possible to form the triangle or 'N' if you can not form a triangle.

Input Example Output Example

6 9 22 15 S

14 40 12 60 N

Olimpada Brasileira de Informtica - 2014.


URI Online Judge | 1930

Electrical Outlet
Por Cludio L. Lucchesi, Fbio D. Moreira Brazil

Timelimit: 1

Finally, the team from the University managed to qualify for the Finals of the SBC Programming
Marathon. The three members of the team and their coach are looking forward to represent the
university, and besides trainining very much, prepare with every detail your trip to So Paulo, where
will be held the National Final.

They plan to carry with them all their electronic devices: mobile phone, tablet, laptop, wifi hotspot,
camera, etc, and know they will need several power outlets to connect all these devices. They were
told that the four will be in the same hotel room, but have been advised that in each room there is only
one available power outlet.

Prevented, the three members of the team and the coach bought each a power strip, thus connect
several devices at one outlet of the hotel room; they may also connect one another in strip to further
increase the number of available sockets. However, as the rules have many outlets, they asked you to
write a program that, given the number of outlets in each rule, determine the maximum number of
devices that can be connected to the energy in the same instant.

Entrada

The input consists of a line with four integers T1, T2, T3, T4, indicating the number of taken from each
of the four strips (2 Ti 6).

Sada
Your program should produce a single line containing a single integer indicating the maximum number
of devices that can be connected to the energy in the same instant.

Input Example Output Example

2 4 3 2 8

6 6 6 6 21

2 2 2 2 5

Olimpada Brasileira de Informtica - 2013.

URI Online Judge | 1933

Tri-du
By Ricardo Anido, Universidade Estadual de Campinas Brazil
Timelimit: 1

Tri-du is a card game inspired in the popular game of Truco. The game uses a normal deck of 52
cards, with 13 cards of each suit, but suits are ignored. What is used is the value of the cards,
considered as integers between 1 to 13.

In the game, each player gets three cards. The rules are simple:

A Three of a Kind (three cards of the same value) wins over a Pair (two cards of the same
value).
A Three of a Kind formed by cards of a larger value wins over a Three of a Kind formed by
cards of a smaller value.

A Pair formed by cards of a larger value wins over a Pair formed by cards of a smaller value.

Note that the game may not have a winner in many situations; in those cases, the cards are returned
to the deck, which is re-shuffled and a new game starts.

A player received already two of the three cards, and knows their values. Your task is to write a
program to determine the value of the third card that maximizes the probability of that player winning
the game.

Input
The input contains several test cases. In each test case, the input consists of a single line, which
contains two integers A (1 A 13) and B (1 B 13) that indicates the value of the two first
received cards.

Output
For each test case in the input, your program must produce a single line, containing exactly one
integer, representing the value of the card that maximizes the probability of the player winning the
game.

Input Example Output Example

10 7 10

2 2 2
XX Maratona de Programao da SBC 2015

URI Online Judge | 1957

Converting to Hexadecimal
By M.C. Pinto, UNILA Brazil

Timelimit: 1
Data stored in computers are in binary. An economic way of visualizing these numbers is the usage of
base 16 (hexadecimal).

Your task is to write a program that, given a natural number at base 10, shows its representation in
hexadecimal.

Input

The input is a positive integer number V at base 10 (1 V 2 x 109).

Output

The output is the same number V at base 16 in a single line (don't forget the end-of-line character).
Use uppercase letters, as shown in the examples.

Input Samples Output Samples

10 A

15 F

16 10

31 1F

65535 FFFF

Exam 1 of Computer Programming at UNILA (2015, semester 2)


URI Online Judge | 1958

Scientific Notation
By M.C. Pinto, UNILA Brazil

Timelimit: 1

Floating point numbers can be very long to show. In these cases, it is convenient to use the scientific
notation.

You must write a program that, given a floating point number, shows this number in scientific notation:
always show the mantissa sign; always show the mantissa with 4 decimal places; use the character
'E' between the mantissa and the exponent; always show the exponent sign; and show the exponent
with at least 2 digits.

Input

The input is a double precision floating point number X (according to the IEEE 754-2008 standard).
There will never be a number with more than 110 characters long and more than 6 decimal places.

Output

The output is the number X in a single line using the scientific notation detailed above. See the
examples below.

Input Samples Output Samples

3.141592 +3.1416E+00

1.618033 +1.6180E+00

602214085774747474747474 +6.0221E+23
-0.000027 -2.7000E-05

-
100000000000000000000000000000000000000000000000000000000000000000000000000000
0000000000000000

Exam 1 of Computer Programming at UNILA (2015, semester 2)

URI Online Judge | 1959

Regular Simple Polygons


By M.C. Pinto, UNILA Brazil

Timelimit: 1

In Euclidean geometry, a regular polygon is a polygon that is equiangular (all angles are equal in
measure) and equilateral (all sides have the same length). A simple polygon is one that does not
intersect itself anywhere. Below we can see various mosaics made of regular polygons.
You must write a program that, given the number and the length of sides of a regular polygon, show
its perimeter.

Input

The input are two positive integers: N and L, which are, respectively, the number of sides and the
length of each side of a regular polygon (3 N 1000000 and 1 L 4000).

Output

The output is the perimeter P of the regular polygon in a single line.

Input Samples Output Samples

3 1 3

9 8 72

1000000 1000 1000000000

Exam 1 of Computer Programming at UNILA (2015, semester 2)


URI Online Judge | 1960

Roman Numerals for Page Numbers


By M.C. Pinto, UNILA Brazil

Timelimit: 1

The ECI (Editio Chronica Incredibilis or Amazing Chronicles Editors) is very traditional when
numbering the pages of its books. It always uses the Roman numerals for that. And its books never
have more than 999 pages. When necessary, the books are split into volumes.

You must write a program that, given an arabic number, show its equivalent in roman numerals.

Remember that I stands for 1, V for 5, X for 10, L for 50, C for 100, D for 500 and M stands for 1000.

Input

The input is a positive integer number N (0 < N < 1000).

Output

The output is the number N written as Roman numerals in a single line. Always use uppercase letters.

Input Samples Output Samples

666 DCLXVI

83 LXXXIII

999 CMXCIX
URI Online Judge | 1961

Jumping Frog
By M.C. Pinto, UNILA Brazil

Timelimit: 1

In each stage of the Jumping Frog game you must safely get your amphibian through a sequence of
pipes of different heights to the rightmost pipe. Nevertheless the frog just survives if the height
difference of consecutive pipes is at most the frog jump height. If the next pipe height is too high, the
frog hits the pipe and fall. If the next pipe height is too low, the frog does not survive the fall. The frog
always starts on the top of the leftmost pipe.

In this game the distance of pipes is irrelevant, which means that the frog always can reach the next
pipe with a jump.

You must write a program that, given the pipe heights and the frog jump height, show if the game
stage can be beaten or not.

Input

The input is given in two lines. The first one has two positive integer numbers P and N, the frog jump
height and the number of pipes (1 P 5 and 2 N 100). The second line has N positive integer
numbers that indicate the pipes heights ordered from left to right. There are no height greater than 10.
Output

The output is given in a single line. If the frog can reach the rightmost pipe write "YOU WIN". If the
frog fails, write "GAME OVER".

Input Samples Output Samples

5 10 YOU WIN
1 3 6 9 7 2 4 5 8 3

1 2 YOU WIN
2 2

1 2 GAME OVER
1 3

URI Online Judge | 1962

A Long, Long Time Ago


By M.C. Pinto, UNILA Brazil

Timelimit: 1

Raul Seixas sang that he was born 10 thousand years ago and there was nothing in this world that he
cannot know too much. The Mamomas Assassinas band sang that more than 10 thousand years
"have gone by and passed" [sic] since they have failed at 5th grade. So many past events and
professor MC was curious about what year each of these have happened.

You must write a program that, given a series of how many years have passed, show, for each
number, in what year the event had happened. Remember that you must indicate if it had happened
BC (Before Christ) or AD (Anno Domini). Use the portuguese A.C. for BC and D.C. for AD according to
the output sample.

Input

The input has several lines. The first one has a positive integer number N (1 N 100000). There
are N lines after the first one. Each of these N lines has a single non negative integer T, which
indicates how many years have passed until 2015 AD (0 T < 231).

Output
The output has N lines. In each one there is the year A in which the correspondent time T had
happened. Look at the sample output.

Input Sample Output Sample

3 7986 A.C.
10000 2000 D.C.
15 1 A.C.
2015

Exam 1 of Computer Programming at UNILA (2015, semester 2)

URI Online Judge | 1963

The Motion Picture


By Leandro Zatesko, UFFS Brazil

Timelimit: 1

Welcome to the 3rd UFFS Junior Programming Contest. We sincerely hope the next hours are very
productive to you, you get many balloons and, above all, you have fun! Remember that you can ask
for a clarification whenever you are not sure that you understand a problem description. Remember
also that at 17.30 the automatic judges will be turned off and the competition will enter blind mode, so
that all submissions made during this period will begin to be judged only at 18.10. Please stay with us
till the end of the competition, working on solutions for the problems till the last minute, because, as
long as the contest is running, there is still hope!
And it was hope that motivated Grandma Zaz, a 72-year-old lady, to fulfill her dream of starting an
undergraduate course. She is fascinated by everything related to the University: the classes, the
library, the research and extension projects, the refectory, but especially the student card that she can
use to get 50% off cinema tickets. Last week Grandma Zaz and her colleagues went to the cinema to
watch a movie, but they were appalled at the ticket price increase. Disgusted, they decided to make a
protest, scheduled for tomorrow at General Bertaso Square, against the oppressive capitalist system.
Grandma Zaz wants to collaborate with the movement by making a poster with the following
watchword:

HOW ABSURD! THE PRICE OF CINEMA TICKETS HAS RISEN % !!

But she is not good at Math, so she is asking you to helpfully calculate the percentage she needs to
complete the poster.

Input

The only input line consists of two values A and B (0.00 < A B 1000.00), given with exactly two
digits after the decimal point, which represent respectively the old and the new prices of the cinema
tickets.

Output

The only output line shall consist of a single value, representing as a percentage the ticket price
increase. The value shall be followed by the symbol % and shall contain two digits after the decimal
point.

Input Samples Output Samples

20.00 30.00 50.00%

50.00 100.00 100.00%

10.00 10.00 0.00%

3rd UFFS Junior Programming Contest

URI Online Judge | 1973

Star Trek
By Leandro Zatesko, UFFS Brazil

Timelimit: 1

After buying many adjacent farms at the west region of Santa Catarina, the Star family built a single
road which passes by all farms in sequence. The first farm of the sequence was named Star 1, the
second Star 2, and so on. However, the brother who lives in Star 1 has got mad and decided to make
a Star Trek in order to steal sheep from the proprieties of his siblings. But he is definitely crazy. When
passes by the farm Star i, he steals only one sheep (if there is any) from that farm and moves on
either to Star i + 1 or Star i - 1, depending on whether the number of sheep in Star i was, respectively,
odd or even. If there is not the Star to which he wants to go, he halts his trek. The mad brother starts
his Star Trek in Star 1, stealing a sheep from his own farm.

Input

The first input line consists of a single integer N (1 N 106), which represents the number of Stars.
The second input line consists of N integers, such that the ith integer, Xi (1 Xi 106), represents the
initial number of sheep in Star i.

Output

Output a line containing two integers, so that the first represents the number of Stars attacked by the
mad brother and the second represents the total number of non-stolen sheep.

Exemplo de Entrada Exemplo de Sada

8 8 68
1 3 5 7 11 13 17 19

8 7 63
1 3 5 7 11 13 16 19

3rd UFFS Junior Programming Contest


URI Online Judge | 1983

The Chosen
By Victor Jatob, UNIME Brazil

Timelimit: 1

Everyone is talking about the Jatoba Teacher classes. The MEC representatives came to the UNIME
of Lauro de Freitas to know more details about this new way of teaching algorithms. In addition, they
wanted to select one student to participate in the OBI-Tec (Olympiad Informatics Technical Level) and
represent Kroton in the competition, because they know that there are the best. To select the best,
they have available a list of the registration number of each student and their respective notes in the
discipline. Your task is to help the Ministry of Education staff to find students better able to represent
the institution and who knows guarantee your place. If the highest score is not greater than or equal to
8, you should print "Minimum note not reached" .

Input

The file first contains the number of students (3 <= n <= 100) and then the n students bearing the
registration number (0 < m < 1000000) each, followed by the note (0 <= note <= 10.0, with 1 decimal
place).

Obs .: the notes will not be repeated. In other words, has no chance to have two students with the
same note.

Output

You must print the student's registration number with the highest score or "Minimum note not reached"
(without quotes) if no student has taken greater note than or equal to 8.

Input Sample Output Sample

3 1001

1000 5

1001 10

1002 6
4 Minimum note not reached

900775 5.7

201553 7.9

5032 6.2

2088 2.1

4 999999

900775 9.4

999999 9.9

10022 9.7

441002 9.8

I Seletiva MaratonaTEC - Maratona de Programao PRONATEC - UNIME

URI Online Judge | 1984

The Pronalncia Puzzle


By Victor Jatob, UNIME Brazil

Timelimit: 1

NASA scientists have discovered a new exoplanet which is 1 billion light years from earth. The name
of this planet was named Pronalndia in honor of the young scientists being formed in PRONATEC.
But the most amazing is yet to come. Observing the planet they were able to identify that the
inhabitants of Pronalndia were trying to communicate with a number. But the number who have
found is reversed and how they found many of them, they called you to be able to automate this
process. Thus, given a number, your task is to print the invert number.

Input

The file contains only a test line which is the number found (0 < n < 9999999999).
Note.: the read number is too high to store in a variable of type int, so you will need to use the long
type, for reading and printing in C, you should use the %llu.

Output

print read number inverted. Do not forget to print the end of line (\n) else you will receved the
Presentation Error message.

Input Sample Output Sample

1234 4321

9876543210 0123456789

12 21

I Seletiva MaratonaTEC - Maratona de Programao PRONATEC - UNIME

URI Online Judge | 1985

MacPRONALTS
By Victor Jatob, UNIME Brazil

Timelimit: 1
The MacPRONALTS is with a super promotion, exclusive to the contestants of the first Selective
MaratonaTEC. But they had a problem, all runners were trying to buy at the same time, so this
generated a very long queue. The worst is that the cashier girl no have calculator or a program to help
her to calculate more quickly. You are the person that will help the girl and the MacPRONALTS
increase their sells. Bellow has a menu day, that contains the product number and its value.

1001 | R$ 1.50

1002 | R$ 2.50

1003 | R$ 3.50

1004 | R$ 4.50

1005 | R$ 5.50

Input

The first entry is reported the number of purchased products (1 <= p <= 5). For each product follows
the quantity (1 <= q <= 500) that the customer purchased.

Obs .: the product number will not be repeated.

Output

You must print the purchase amount with two decimal places.

Input Sample Output Sample

2 19.50

1001 2

1005 3

1 1750.00

1003 500
5 2808.50

1001 500

1005 300

1003 23

1002 52

1004 44

I Seletiva MaratonaTEC - Maratona de Programao PRONATEC - UNIME

URI Online Judge | 2003

Sunday Morning
By Thalyson Nepomuceno, UECE Brazil

Timelimit: 1

Sunday is market day. Early in the morning many people move to the Parangaba square where
happens a fair, known to be the largest in the city. At the fair the Parangaba you can find everything.

Every Sunday, Bino make purchases at the fair. He always mark with his friend Cino, they met at the
bus terminal of Parangaba at 8 am to go together to buy at the fair. But often Bino wake up too late
and is late for the meeting with his friend.

Knowing that Bino takes 30-60 minutes to reach the terminal. Tell the maximum delay Bino.

Input

The input consists of multiple test cases. Each case contains a single line containing a time H (5:00
H 9:00) that Bino woken up. The input ends with the final file (EOF).

Output

For each test case, print "Atraso maximo: X" (without quotes), X indicates the maximum delay (in
minutes) of Bino in the encounter with Cino.
Input Sample Output Sample

7:10 Atraso maximo: 10


5:00 Atraso maximo: 0

Olimpada Cearense de Informtica - 2015

URI Online Judge | 2006

Identifying Tea
By Ins Kereki Uruguay

Timelimit: 1

Blind tea tasting is the skill of identifying a tea by using only your senses of smell and taste.

As part of the Ideal Challenge of Pure-Tea Consumers (ICPC), a local TV show is organized. During
the show, a full teapot is prepared and five contestants are handed a cup of tea each. The participants
must smell, taste and assess the sample so as to identify the tea type, which can be: (1) white tea; (2)
green tea; (3) black tea; or (4) herbal tea. At the end, the answers are checked to determine the
number of correct guesses.

Given the actual tea type and the answers provided, determine the number of contestants who got the
correct answer.

Input
The first line contains an integer T representing the tea type (1 T 4). The second line contains five
integers A, B, C, D and E, indicating the answer given by each contestant (1 A, B, C, D, E 4).

Output

Output a line with an integer representing the number of contestants who got the correct answer.

Input Samples Output Samples

1 2
1 2 3 2 1

3 0
4 1 1 2 1

ICPC Latin American Regional 2015

URI Online Judge | 2028

Sequence of Sequence
By Albertinin Mourato, UFPE Brazil

Timelimit: 3

Hyam is a guy that loves sequences. He is finding interesting sequences that even Fibonacci would
not have imagined. One day Hyam saw that given a number N, he could make a sequence like 0 1 2 2
3 3 3 4 4 4 N N N N. However, Hyam saw that each value that increased in the sequence
number, the total quantity increases at a factorial rate. In this case, instead of multiplying, you add the
total number of numbers to the sequence with the value of the next number in the sequence. For
example, if N = 2. The correct sequence would be 0 1 2 2, which is 4 digits. Now, if N = 3, the next
number in the sequence would have the value 3, so the total quantity of numbers in the sequence
would bem the quantiy of numbers with N = 2, which is 4, plus the value of the next number in the
sequence, in this case 3, giving you 7, since the correct sequence for N = 3 is 0 1 2 2 3 3 3.

Your task is make an algorithm that given a integer N, has as answer the total quantity of numbers of
this sequence and below the complete sequence.

Input

The input consists of several test cases. Each case is composed of an integer N (0 <= N <= 200) that
indicates the last value of the last N numbers of the sequence numbers.
The input ends with end of file (EOF).

Output

The output is in format Case X: N numbers where X is the order of number of cases and N is the
number of numbers that contains the complete sequence, the next line sequence numbers with a
space between them. You are asked to leave a blank line after each case.

Input Sample Output Sample

0 Caso 1: 1 numero

1 0

3 Caso 2: 2 numeros

0 1

Caso 3: 4 numeros

0 1 2 2

Caso 4: 7 numeros
Input Sample Output Sample

0 1 2 2 3 3 3

URI Online Judge | 2029

Honey Reservoir
By Deoclcio Lima, UNIP Brazil

Timelimit: 1

Your Julius owner of a apirio grando cituado inside the paraba. Every year, every six months, his
Julius collecting honey produced by bees of their property and stores it in a CYLINDRICAL container
format that facilitates the transport of honey for establishments who order this natural product for
commercialization . Once your Jlio realized due to an increase in honey production, over the previous
six months, the container that owned the stand the volume of honey produced by his bees. Julius your
needs now that vocfaa a program that informed the volume of honey in cm 3 and the diameter of the
inside of the container in cm, calculate and show:

- What should be the height (in cm) of Inside the container;

- The area (in cm2) of the mouth (entrance) of the container.

NB .: Consider = 3.14

Input

The input contains several test cases and ends with EOF. Each test case consists of a line containing
two floating-point values of double precision with two decimals after comma, one V (1.00 V
10000.00) and one D (1.00 D 100.00), respectively representing the volume and the container
diameter.

Output

For each test, the output contains the first line "ALTURA = " message, with a space after ALTURA and
another after the symbol of equality, followed by the container height value with two decimals after
comma and the second line message "AREA = ", also with a space after AREA and another after the
symbol of equality, followed by the value of the area of the mouth (entrance) of the container with two
decimals after comma.

- Do not forget the line break at the end of the exit, otherwise you will get "Presentation Error".
Input Sample Output Sample

1450.00 ALTURA = 2.96


25.00 AREA = 490.62
760.00 ALTURA = 0.61
40.00 AREA = 1256.00
7500.00 ALTURA = 42.46
15.00 AREA = 176.62

Dedicated to Team Los Miserables and GTI Group of the UNIP, 2015.

RI Online Judge | 2031

Rock, Paper, Airstrike


By Jeremias Gomes, Universidade de Braslia Brazil
Timelimit: 1

Rock, Paper, Airstrike is a very popular childrens game, in which two or more children form a circle
and do hand gestures in an attempt to get the victory. The rules are surprisingly complex for a
childrens game, but its still quite popular around the world.

The games are very simple. Players can choose between the sign of a Rock (fist), the sign of a paper
(an open palm), and the signal to the Air Attack (like the paper, but with only the thumb and little finger
extended).
A game with two players have the following rules to determine a winner:

Airstrike vs. Rock: In this case, the player with Airstrike defeats the player with Rock for
obvious reasons.

Rock vs. Paper: In this case the player with Rock defeats the one with Paper, because Rock
hurts more.

Paper vs. Airstrike: In here Airstrike wins because Airstrike always wins and Paper is pathetic.

Paper vs. Paper: In this variation both players win because Paper is useless and no one
facing Paper can lose.

Rock vs. Rock: To this case there is no winner because it depends on what the players decide
to do with the Rock and usually do nothing at the end.

Airstrike vs. Airstrike: When this happens all players lose due to Mutual Annihilation.
Your task is to write a program that given the choice of two players tell who won the game.

Input
The input consist of N (1 N 1000) test cases. N should be read in the first line of input. Each test
case is composed of two lines each containing a string. The first string is the sign chosen by Player 1
and the second string is the sign chosen by the Player 2. These string can be:

ataque: to represents Airstrike

pedra: to represents Rock

papel: tp represents Paper

Output
The output must be contain:

Jogador 1 venceu: if Player 1 has won the game

Jogador 2 venceu: if Player 2 has won the game

Ambos venceram: if the both have won the game

Sem ganhador: if there is no winner

Aniquilacao mutua: if Mutual Annihilation occurs

Each output of a test case must be in one line.

Input Sample Output Sample

2 Sem ganhador
pedra Jogador 1 venceu
pedra
ataque
papel
Warmup of III Maratona de Programao do IFG - Formosa

URI Online Judge | 2057

Time Zone
By Neilor Tonin, URI Brazil

Timelimit: 1

Paul and Peter have made a long journey since they left Brazil to compete in the ICPC World Finals,
in Phuket, Thailand. They noticed that in each place where they stopped, they had to adjust their
watches because of the time zone.

This way, to plan for upcoming trips, they asked you to create a mobile application that, given the
departure time, travel time and the destination time zone with respect to the origin, you have to inform
the time of arrival of each flight in the destination.

For example, if they left a place at 10 am for a 4 hour journey to a destination that is on the east, in a
time zone with an extra hour with respect to the time zone of the starting point, the arrival time will be
10 hours + 4 hours + 1 hour (due de time zone), i.e. they will arrive at 15 hours. Note that if the
calculated time is 24, its program should print 0 (zero).

Input

La entrada contiene tres enteros: S (0 S 23), T (1 T 12) y F (-5 F 5), separado por el
espacio, indicando respectivamente la hora local de salida, el viaje en el tiempo y la zona horaria de
destino con relacin al origen.

Output

Imprimir lo nmero entero que indica la hora local esperada en el destino, segn los ejemplos abajo.

Input Samples Output Samples

10 7 3 20

2
22 6 -2

23
0 3 -4

Aquecimento para a OBI 2016


Acknowledgments to Jean Bez
URI Online Judge | 2059

Odd, Even or Cheating


By Marianne Linhares, UFCG Brazil

Timelimit: 1

A new game called Odd, Even or Cheating is currently (OEC) is now one of the most popular games
in the world. This game was created when some friends had no internet connection, no cellphone, no
computer, and pretty much nothing to do. The game is so popular that is going to happen the mundial
championship of OEC and each country of the world will choose a representant to compete in this
championship.

The game works like this: it's a two players game, the player 1 chooses between odd or even, then
each player chooses a positive integer, if the sum of these number is even and player 1 chose even,
then player 1 wins, if the sum is odd and player 2 chose odd, then player 2 wins. If player 1 chooses
odd he/she wins when the sum is odd, and player 2 wins when the sum is even. Nothing new, right?

But now there are two more possible moves, player 1 can cheat to make sure that he/she wins
independently of the result of the conventional odd or even game, and player 2 can accuse player 1 of
cheating. With these additions in the game if player 1 cheats and player 2 accuses him/her of cheating
player 2 wins, if player 2 don't accuse and player 1 is cheating then player 1 wins, if player 2 accuses
the cheat, but player 1 is not cheating then player 1 wins, if player 1 isn't cheating and player 2 doesn't
accuse player 1 then the game will be played as described previously.

You were hired by OECIO (Odd, Even or Cheating International Organization) to develop a program
that given an OEC match it determines the winner.

Input

The input consists of one line with 5 integers: p, j1, j2, r, a. ( 0 p, r, a 1 e 1 j1, j2 100).

p is the player 1 choice (if p = 1 then player 1 chooses even, if p = 0 then player 1 chooses
odd). j1, j2, represents respectively the numbers that player 1 chose and the number that player 2
chose. r represents if player 1 cheated (if r = 1 then player 1 cheated, if r = 0 then he/she did
not), a represents if player 2 accused player 1 of cheating (if a = 1 then he/she did, if a = 0 then
he/she did not).

Output

Print "Jogador 1 ganha!" if player 1 won or "Jogador 2 ganha!" if player 2 won (no quotation marks).
Input Samples Output Samples

1 4 5 0 0 Jogador 2 ganha!

1 4 5 1 0 Jogador 1 ganha!

1 4 5 1 1 Jogador 2 ganha!

Aquecimento para a OBI 2016

URI Online Judge | 2060

Bino's Challenge
By Thalyson Nepomuceno, UECE Brazil

Timelimit: 1

Bino and Cino are close friends. Bino likes to create mathematical challenges to Cino. This time, Bino
created a list of numbers and asked to Cino: How many numbers are multiples of 2, 3, 4 and 5?

This challenge looks simple, but when the list contains many numbers, Cino makes some
miscalculations. To help Cino, make a program to solve the Bino's Challenge.

Input

The first line of input consists of an integer N (1 N 1000), representing the amount of numbers in
the Bino's list.

The second line contains N integers Li (1 Li 100), representing the numbers of the Bino's list.

Output

Print the amount of multiples of 2, 3, 4 and 5 in the list. Note the formatting of the output in the output
sample, because it must be followed strictly. "Multiplo(s)" means "Multiple(s)" in English, but you must
print the message in Portuguese.
Input Sample Output Sample

5 4 Multiplo(s) de 2
2 5 4 20 10 0 Multiplo(s) de 3
2 Multiplo(s) de 4
3 Multiplo(s) de 5

Aquecimento para a OBI 2016

URI Online Judge | 2061

Closing Tabs
By Lucas Hermann Negri, UTFPR Brazil

Timelimit: 1

Pricles has an unique interest in history. With his up-to-date internet browser chromed fox, he
wandered in the most obscure sites about ancient Greek mythology.

By some type of cosmic irony, Pricles' browser was infected by a malware with a peculiar
characteristic: every time Pricles closed a tab in his browser, another two opened! However, when
Pricles clicked one of the ads (all tabs were infested with ads), the tab crashed, and no other tabs
were opened.
Your taks is to compute the final number of tabs of Pricles's browser, knowing the initial number of
tabs and the actions taken by Pricles. There are two possible actions: fechou (when Pricles closed
a tab) and clicou (when Pricles clicked on an ad).

Input

The input is initiated by a line containing two integer numbers, N e M (0 < N, M < 500), representing
the initial number of tabs and the number of actions performed by Pricles. Each subsequent line
contains an action (fechou or clicou). Naturally, the current number of tabs is always greater of equal
to zero.

Output

The output must consist of a line containing the final number of tabs.

Input Sample Output Sample

3 5 2
fechou
fechou
clicou
clicou
clicou

Aquecimento para a OBI 2016

Das könnte Ihnen auch gefallen