# N M 5

**문제 설명**

![](https://3269900549-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MIbwNq54Ge4eqsziHM7%2F-Ma7R4nxNy14hLzG1NST%2F-Ma7kWLm2krUs2-G8MSH%2FScreen%20Shot%202021-05-20%20at%204.51.08%20PM.png?alt=media\&token=19150be9-c9c7-4601-9501-d22be27d7373)

![입출력 예시](https://3269900549-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MIbwNq54Ge4eqsziHM7%2F-Ma7R4nxNy14hLzG1NST%2F-Ma7km1ZNYgVEOlPL1mF%2Fimage.png?alt=media\&token=cf0f5420-2090-481a-92bd-9f0761316a1e)

N개의 서로 다른 수가 주어지고, 이 중에서 M개를 골라 수열을 만든다.

N개의 서로 다른 수이지만 이것은 배열로 num\[1],num\[2],num\[3]..으로 나타낼 수 있고, 앞에서 1부터 N까지 자연수였다면 이 문제에서는 인덱스가 1부터 N-1까지인 수라고 할 수 있다.

수열 배열에 a\[index] = i (0<=index<=m, 1<=i<=m) 이였다면\
이 문제에서는 a\[index] = num\[i] (0<=index<=m, 0<=i<=n-1) 이 된다.\
**num배열**에서 **사용한 인덱스**는 **true로 처리**하고, **수열 생성했다면 다시 false**처리해준다.

```java
for(int i=0;i<n;i++) {
			if(c[i]) continue;
			c[i] = true;a[index] = num[i];
			ans.append(go(num,index+1,n,m));
			c[i] = false;
}
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://heunnajo.gitbook.io/algorithms-problem-solving-skills/brute-force/nm-5.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
