반응형
문제
기억력 테스트 2
첫째줄에 N이 입력된다. (1 <= N <= 10,000,000) 둘째 줄에 N개의 숫자가 공백으로 구분되어 차례대로 입력된다. ( 데이터값의 범위 : 1 ~ 10,000,000) 셋째줄에 질문의 수 M이 입력된다. ( 1 <= M <= 100,000) 넷째
codeup.kr
코드
#include <stdio.h>
#include <stdlib.h>
int main()
{
short arr[10000001];
arr[0] = 0; //초기화
int n; //n개 숫자 기억
scanf("%d", &n);
//입력 받기
int idx;
for(int i=0; i<n; i++){
scanf("%d", &idx);
arr[idx] = 1;
}
int m; //m개의 질문 받음
int x;
scanf("%d", &m);
for(int i=0; i<m; i++){
scanf("%d", &x);
printf("%d ", arr[x]);
}
return 0;
}
반응형
'개발 > 알고리즘' 카테고리의 다른 글
codeup 1902 (0) | 2021.03.17 |
---|---|
codeup 1901 (0) | 2021.03.17 |
[프로그래머스] 3진법 뒤집기 (0) | 2021.03.13 |
[프로그래머스] 2016년 (0) | 2021.03.11 |
프로그래머스 체육복 (0) | 2021.03.11 |
최근댓글