반응형
https://www.acmicpc.net/problem/6768
6768번: Don’t pass me the ball!
A CCC soccer game operates under slightly different soccer rules. A goal is only counted if the 4 players, in order, who touched the ball prior to the goal have jersey numbers that are in strictly increasing numeric order with the highest number being the
www.acmicpc.net
조합 문제였습니다.
📕 풀이방법
📔 입력 및 초기화
골을 넣은 플레이어의 번호 n을 선언 후 입력받습니다.
📔 풀이과정
골을 넣은 플레이어는 4명 중 가장 높은 수를 가지고 있습니다. 따라서 이 결과가 바뀌지 않으려면 1 ~ n -1의 번호들 중 3명의 플레이어를 결정하면 됩니다. 따라서 조합을 생각하게 되며 n-1C3의 값을 출력하면 됩니다.
📔 정답출력
n-1C3의 결과를 출력합니다.
📕 Code
#include <bits/stdc++.h>
using namespace std;
int n, ans = 1;
int main(){
cin >> n;
for(int i = 1; i <= 3; i++) ans *= n - i;
cout << ans / 6;
}
'Algorithm > Math' 카테고리의 다른 글
(C++) - 백준(BOJ) 21771번 : 가희야 거기서 자는 거 아니야 (0) | 2021.09.13 |
---|---|
(C++) - 백준(BOJ) 8718번 : Bałwanek (0) | 2021.09.12 |
(C++) - 백준(BOJ) 1173번 : 운동 (0) | 2021.08.18 |
(C++) - 백준(BOJ) 1284번 : 집 주소 (0) | 2021.08.15 |
(C++) - 백준(BOJ) 13458번 : 시험감독 (0) | 2021.08.02 |