URI Online Judge | 1094
Experiências
Adaptado por Neilor Tonin, URI
Brasil
Timelimit: 1
Brasil
Maria acabou de iniciar seu curso de graduação na faculdade de medicina e precisa de sua ajuda para organizar os experimentos de um laboratório o qual ela é responsável. Ela quer saber no final do ano, quantas cobaias foram utilizadas no laboratório e o percentual de cada tipo de cobaia utilizada.
Este laboratório em especial utiliza três tipos de cobaias: sapos, ratos e coelhos. Para obter estas informações, ela sabe exatamente o número de experimentos que foram realizados, o tipo de cobaia utilizada e a quantidade de cobaias utilizadas em cada experimento.
Entrada
A primeira linha de entrada contém um valor inteiro N que indica os vários casos de teste que vem a seguir. Cada caso de teste contém um inteiro Quantia (1 ≤ Quantia ≤ 15) que representa a quantidade de cobaias utilizadas e um caractere Tipo ('C', 'R' ou 'S'), indicando o tipo de cobaia (R:Rato S:Sapo C:Coelho).
Saída
Apresente o total de cobaias utilizadas, o total de cada tipo de cobaia utilizada e o percentual de cada uma em relação ao total de cobaias utilizadas, sendo que o percentual deve ser apresentado com dois dígitos após o ponto.
URI Online Judge | 1094
Experiments
Adapted by Neilor Tonin, URI
Brazil
Timelimit: 1
Brazil
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 character Type('C', 'R' or 'S'), indicating the type of animal:
- C: Coelho (rabbit in portuguese)
- R: Rato (rat in portuguese)
- S: Sapo (frog in portuguese)
- 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.
n = int(input())
c = 0
r = 0
s = 0
for i in range(1 , n + 1):
x = input().split()
a, b, = x
if b == 'C':
c = c + int(a)
if b == 'R':
r = r + int(a)
if b == 'S':
s = s + int(a)
total = c + r + s
pc = (c / total) * 100
pr = (r / total) * 100
ps = (s / total) * 100
print('Total: {} cobaias'.format(total))
print('Total de coelhos: {}'.format(c))
print('Total de ratos: {}'.format(r))
print('Total de sapos: {}'.format(s))
print('Percentual de coelhos: {:.2f} %'.format(pc))
print('Percentual de ratos: {:.2f} %'.format(pr))
print('Percentual de sapos: {:.2f} %'.format(ps))
n = int(input())
c = 0
r = 0
s = 0
for i in range(1 , n + 1):
x = input().split()
a, b, = x
if b == 'C':
c = c + int(a)
if b == 'R':
r = r + int(a)
if b == 'S':
s = s + int(a)
total = c + r + s
pc = (c / total) * 100
pr = (r / total) * 100
ps = (s / total) * 100
print('Total: {} cobaias'.format(total))
print('Total de coelhos: {}'.format(c))
print('Total de ratos: {}'.format(r))
print('Total de sapos: {}'.format(s))
print('Percentual de coelhos: {:.2f} %'.format(pc))
print('Percentual de ratos: {:.2f} %'.format(pr))
print('Percentual de sapos: {:.2f} %'.format(ps))
Nenhum comentário:
Postar um comentário