## Algorithm

Problem Name: beecrowd | 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 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)

## 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 10 C 6 R 15 S 5 C 14 R 9 C 6 R 8 S 5 C 14 R Total: 92 cobaias Total de coelhos: 29 Total de ratos: 40 Total de sapos: 23 Percentual de coelhos: 31.52 % Percentual de ratos: 43.48 % Percentual de sapos: 25.00 %

## Code Examples

### #1 Code Example with C Programming

```Code - C Programming```

``````

#include<stdio.h>
int main()
{
int i,n,m;char a,b;int sum=0,sum1=0,sum2=0,sum3;
double t,l,y;
b='%';
scanf("%d",&m);
for(i=1;i < =m;i++){

scanf("%d %c",&n,&a);
if('C'==a){
sum=sum+n;
}
if('R'==a){
sum1=sum1+n;
}
if('S'==a){
sum2=sum2+n;
}
}
sum3=sum+sum1+sum2;
t=(sum/(sum3*1.0))*100.00;
l=(sum1/(sum3*1.0))*100.00;
y=(sum2/(sum3*1.0))*100.00;
printf("Total: %d cobaias\n",sum3);
printf("Total de coelhos: %d\n",sum);
printf("Total de ratos: %d\n",sum1);
printf("Total de sapos: %d\n",sum2);
printf("Percentual de coelhos: %.2lf %c\n",t,b);
printf("Percentual de ratos: %.2lf %c\n",l,b);
printf("Percentual de sapos: %.2lf %c\n",y,b);
}
``````
Copy The Code &

Input

cmd
10 10 C 6 R 15 S 5 C 14 R 9 C 6 R 8 S 5 C 14 R

Output

cmd
Total: 92 cobaias Total de coelhos: 29 Total de ratos: 40 Total de sapos: 23 Percentual de coelhos: 31.52 % Percentual de ratos: 43.48 % Percentual de sapos: 25.00 %

### #2 Code Example with C++ Programming

```Code - C++ Programming```

``````
#include <iostream>
#include <stdio.h>

using namespace std;

int main(){
int n;
int q;
char t;
int total = 0;
int coelho = 0;
int sapo = 0;
int rato = 0;

cin >> n;

for(int i = 0; i  <  n; i++){
cin >> q;
cin >> t;

total += q;

if(t == 'C') coelho += q;
if(t == 'S') sapo += q;
if(t == 'R') rato += q;
}

cout << "Total: " << total << " cobaias\n";
cout << "Total de coelhos: " << coelho << "\n";
cout << "Total de ratos: " << rato << "\n";
cout << "Total de sapos: " << sapo << "\n";
printf("Percentual de coelhos: %.2f %\n", ((float)coelho/(float)total)*100.00);
printf("Percentual de ratos: %.2f %\n", ((float)rato/(float)total)*100.00);
printf("Percentual de sapos: %.2f %\n", ((float)sapo/(float)total)*100.00);
return 0;

}
``````
Copy The Code &

Input

cmd
10 10 C 6 R 15 S 5 C 14 R 9 C 6 R 8 S 5 C 14 R

Output

cmd
Total: 92 cobaias Total de coelhos: 29 Total de ratos: 40 Total de sapos: 23 Percentual de coelhos: 31.52 % Percentual de ratos: 43.48 % Percentual de sapos: 25.00 %

### #3 Code Example with Python Programming

```Code - Python Programming```

``````
n=int(input())
C=0
R=0
S=0
for i in range(n):
a,ch=list(map(str,input().split()))
a=int(a)
if(ch == 'C'):
C += a
elif (ch == 'R'):
R += a
else:
S += a
total=C+R+S
x=(C*100.00)/total
y=(R*100.00)/total
z=(S*100.00)/total
print("Total: {} cobaias".format(total))
print("Total de coelhos:",C)
print("Total de ratos:",R)
print("Total de sapos:",S)
print("Percentual de coelhos: %.2lf %%"%x)
print("Percentual de ratos: %.2lf %%"%y)
print("Percentual de sapos: %.2lf %%"%z)
``````
Copy The Code &

Input

cmd
10 10 C 6 R 15 S 5 C 14 R 9 C 6 R 8 S 5 C 14 R

Output

cmd
Total: 92 cobaias Total de coelhos: 29 Total de ratos: 40 Total de sapos: 23 Percentual de coelhos: 31.52 % Percentual de ratos: 43.48 % Percentual de sapos: 25.00 %