슈콩

[BOJ] 백준 1920 수 찾기 본문

Algorithms/Baekjoon

[BOJ] 백준 1920 수 찾기

shukong 2025. 9. 16. 19:41

[문제]

https://www.acmicpc.net/problem/1920

 

 

[소스 코드]

import java.io.*;
import java.util.*;
public class Main {
	public static void main(String[] args) throws IOException {
		HashSet<Integer> hs = new HashSet<>();
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st;
		int n = Integer.parseInt(br.readLine());
		st = new StringTokenizer(br.readLine());
		for(int i=0;i<n;i++) {
			hs.add(Integer.parseInt(st.nextToken()));
		}
		int m = Integer.parseInt(br.readLine());
		st = new StringTokenizer(br.readLine());
		for(int i=0;i<m;i++) {
			if(hs.contains(Integer.parseInt(st.nextToken()))) {
				System.out.println(1);
			}
			else
				System.out.println(0);
		}
	}
}

'Algorithms > Baekjoon' 카테고리의 다른 글

[BOJ] 백준 18870 좌표 압축  (0) 2025.09.16
[BOJ] 백준 10816 숫자 카드 2  (0) 2025.09.16
[BOJ] 백준 9613 GCD 합  (0) 2025.09.16
[BOJ] 백준 9020 골드바흐의 추측  (0) 2025.09.15
[BOJ] 백준 6359 만취한 상범  (0) 2025.09.15