백준 11549 자바
Identifying tea 다국어
문제
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.
입력
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 a line with an integer representing the number of contestants who got the correct answer.
예제 입력 1
1
1 2 3 2 1
예제 출력 1
2
예제 입력 2
3
4 1 1 2 1
예제 출력 2
0
시간 제한 메모리 제한 제출 정답 맞힌 사람 정답 비율
3 초 | 256 MB | 2375 | 2113 | 1994 | 89.699% |
T는 차 종류
(1) white tea; (2) green tea; (3) black tea; or (4) herbal tea.
몇종류인지 맞춘사람 개수
코드
package Day0927;
import java.util.Scanner;
public class B11549 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int T = sc.nextInt(); // 차 종류
int[] arr = new int[5];
//참가자 정답 입력
for (int i = 0; i < arr.length; i++) {
arr[i] = sc.nextInt();
}
// 정답자 카운트해주기
int cnt = 0;
for (int i = 0; i < arr.length; i++) {
if (arr[i] == T) {
cnt++;
}
}
System.out.println(cnt);
sc.close();
}
}
'알고리즘 공부 > 백준 문제풀이' 카테고리의 다른 글
[백준] 8393 : 합 (JAVA) (0) | 2022.10.06 |
---|---|
[백준] 14470 : 전자레인지(JAVA) (1) | 2022.10.06 |
[백준]10953 : A+B-6 (JAVA) (1) | 2022.10.06 |
[백준] 2588 : 곱셈 (JAVA) (0) | 2022.10.05 |
[백준] 2441 : 별 찍기 -4(JAVA) (0) | 2022.10.05 |