백준 3049 다각형의 대각선 c++

치즈·2022년 10월 1일

BOJ

목록 보기
3/45

Silver 5 문제

다각형의 대각선의 교점의 수 : nC4

#include <iostream>

using namespace std;
int combination(int n, int r){
  if(n==r || r ==0) return 1;
  else return combination(n-1, r-1) + combination(n-1, r);
}
void solve(){
  int N;
  cin >> N;
  if(N < 4) cout << 0;
  else cout << combination(N, 4);
}


int main(void){
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  solve();
 
  return 0;
}
profile
차근차근 배워나가요

0개의 댓글