본문 바로가기 메뉴 바로가기

henry's PS diary

프로필사진
  • 글쓰기
  • 관리
  • 태그
  • 방명록
  • RSS

henry's PS diary

검색하기 폼
  • 분류 전체보기 (309)
    • Programming (2)
      • C (2)
    • Algorithm (193)
      • Theory (1)
      • BOJ (148)
      • ALGOSPOT (17)
      • SW Expert Academy (24)
      • LeetCode (1)
      • Codeforces (2)
    • Master 1000 Sentences (113)
      • SOM (2)
      • Script (2)
      • QOD (104)
      • World News (5)
    • Daily (1)
  • 방명록

Algorithm/Theory (1)
n개의 원소 중 m개를 고르는 모든 조합을 찾는 알고리즘

0~n-1까지 n개의 원소가 있을 때 그 중 m개를 고르는 모든 조합을 출력한다. n: 전체 원소 수 picked: 지금까지 고른 원소들의 번호 toPick: 더 고를 원소의 수 #include #include using namespace std; void printPicked(vector picked) { for(int i : picked) printf("%d ",i); printf("\n"); } void pick(int n,vector& picked,int toPick) { if(toPick==0) { printPicked(picked); return; } int smallest=picked.empty()?0:picked.back()+1; for(int next=smallest;next

Algorithm/Theory 2021. 6. 7. 10:14
이전 1 다음
이전 다음
링크
  • 알고리즘 교육 프로그램 소개
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday

Blog is powered by Tistory / Designed by Tistory

티스토리툴바