---
layout: post
title:  "[BOJ] 10816. 숫자 카드2"
categories: Algorithm
tags: BOJ
author: goodGid
---
* content
{:toc}

## Problem

Problem URL : **[숫자 카드2](https://www.acmicpc.net/problem/10816)**












![](/assets/img/algorithm/10816_1.png)

![](/assets/img/algorithm/10816_2.png)

---


## [1] Answer Code (18. 09. 26)

``` cpp
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;

int main(void) {
    int n;
    scanf("%d", &n);
    vector<int> v;
    for (int i = 0; i < n; i++) {
        int num;
        scanf("%d", &num);
        v.push_back(num);
    }
    sort(v.begin(), v.end());
    scanf("%d", &n);
    for (int i = 0; i < n; i++) {
        int num;
        scanf("%d", &num);
        if (binary_search(v.begin(), v.end(), num) == 0) {
            printf("0 ");
        }
        else{
            printf("%ld ", upper_bound(v.begin(), v.end(), num) - lower_bound(v.begin(), v.end(), num));
        }
    }
}
```

### Review

* upper_bound 와 Lower_bound 함수에 대해 모르겠으면 [Upper_bound vs Lower_bound]({{site.url}}/Upper-Lower/))을 참고하자.
Write BOJ Post " 10816. 숫자 카드2 "
Write BOJ Post " 10816. 숫자 카드2 "
