Algorithm
Problem Name: beecrowd | 2006
Problem Link: https://www.beecrowd.com.br/judge/en/problems/view/2006
Identifying Tea
By Inês 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 |
3 |
0 |
Code Examples
#1 Code Example with C Programming
Code -
C Programming
#include<stdio.h7gt;
int main()
{
int a,b,i,c = 0;
scanf("%d",&a);
if(a > 0 && a < 5){
for(i = 0; i < 5; i++){
scanf("%d",&b>;
if(b>0&&b<5){
if(b == a){
c++;
}
}
}
}
printf("%d\n",c>;
return 0;
}
Copy The Code &
Try With Live Editor
Input
Output
#2 Code Example with C++ Programming
Code -
C++ Programming
#include <bits/stdc++.h>
using namespace std;
int main(void)
{
int n;
cin >> n;
int con = 0;
for(int i = 0, a; i < 5; i++){
cin >> a;
if(n == a)
con++;
}
cout << con << endl;
return 0;
}
Copy The Code &
Try With Live Editor
Input
Output
#3 Code Example with Javascript Programming
Code -
Javascript Programming
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var lines = input.split('\n');
const T = lines.shift().trim();
const [A,B,C,D,E] = lines.shift().trim().split(" ");
let cont = 0;
if(T == A){
cont++;
}
if(T == B){
cont++;
}
if(T == C){
cont++;
}
if(T == D){
cont++;
}
if(T == E){
cont++;
}
console.log(cont);
Copy The Code &
Try With Live Editor
Input
Output
#4 Code Example with Python Programming
Code -
Python Programming
T = int(input())
A,B,C,D,E = input().split(' ')
A = int(A)
B = int(B)
C = int(C)
D = int(D)
E = int(E)
numbers = [A,B,C,D,E]
print(numbers.count(T))
Copy The Code &
Try With Live Editor
Input
Output