BOJ-15649

    [백준] BOJ-15649 N과 M (1)

    [백준] BOJ-15649 N과 M (1)

    문제 N과 M을 입력받아 nPm 의 순열을 구하는 문제였다. 풀이 import Foundation let nm = readLine()!.split(separator: " ").map { Int($0)! } let n = nm.first! let m = nm.last! let nums = Array(1...n) // [1, 2, ..., n] /// nPr func permutation(n elements: [Int], r: Int) -> [[Int]] { var result = [[Int]]() var visited = [Bool](repeating: false, count: n) func permu(_ temp: [Int]) { if temp.count == r { result.append(temp) ..