⚠️ 한 번씩 읽어주세요 ⚠️
제 개인의 풀이 방법이며 제 풀이가 꼭 정답은 아닙니다
더 나은 풀이법이 존재할 경우 댓글로 공유해 주시면
저를 포함한 다른 분들에게도 많은 도움이 됩니다
전체 코드는 깃헙 링크 혹은 하단 코드를 통해 확인가능 합니다
| 문제 링크 🔗
3733번: Shares
A group of N persons and the ACM Chief Judge share equally a number of S shares (not necessary all of them). Let x be the number of shares aquired by each person (x must be an integer). The problem is to compute the maximum value of x. Write a program that
www.acmicpc.net
| 문제 설명 ❓
(영어 - English)
(한국어 - Korean)
| 입출력 예시 💬
| 풀이 🔥
처음에는 문제를 이해 못 해서 예시 입력에 따른 출력이 이해가 되지 않아서 몇 번을 더 읽어 봤습니다.
S를 N명의 그룹 + 수석 심판(1)으로 나누라는 의미였습니다.
처음엔 S를 N으로 나누라는 걸로 이해했지만 이렇게 되면 예시 입출력이 맞지 않습니다.
| 전체 코드 🔎
[깃헙 / Github] (IDE: Rider)
GitHub - taehuuun/CodingTest: This is a auto push repository for Baekjoon Online Judge created with [BaekjoonHub](https://github
This is a auto push repository for Baekjoon Online Judge created with [BaekjoonHub](https://github.com/BaekjoonHub/BaekjoonHub). - GitHub - taehuuun/CodingTest: This is a auto push repository for B...
github.com
// 입력 받은 문자열들을 추가하기 위한 리스트
List<string> inputList = new List<string>();
// 빈값, 아무값도 입력 받지 않을 때까지 반복
while (true)
{
// 문자열의 형식으로 입력을 받는다
var input = Console.ReadLine();
// null 혹은 빈값이 입력 되면 while문 break
if (string.IsNullOrEmpty(input))
{
break;
}
// 이외에 값은 리스트에 입력 값을 추가
inputList.Add(input);
}
// 추가된 리스트 개수 만큼 반복
for (int i = 0; i < inputList.Count; i++)
{
// inputList[i]의 문자열을 공백을 기준으로 나눔
string[] splitInput = inputList[i].Split(' ');
// splitInput의 각 요소 값을 정수형으로 파싱하여 n, s에 대입
int n = int.Parse(splitInput[0]);
int s = int.Parse(splitInput[1]);
// 두 값 s를 (수석심판과 그룹 수 (n+1))로 나눈 몫을 출력
Console.WriteLine(s/(n + 1));
}