티스토리 뷰

Difficulty : Gold V

Problem Description

There is 'N' sausages and 'M' food critics.

The output is the smallest count to cut sausages to provide equally sized sausages among food critics.

 

Solution

Think of 'N' sausages as one sausages of length 'N'.

In this case, count is always M-1 because I don't have to cut for the last person.

And if sum of the length of all cut sausages is natural number, I don't have to cut because the sausage is already cut.

There is a picture to describe.

In this case, the default count is 5, but I don't have to count the second cut and the forth count.

So the answer is 5-2=3.

 

The default count is 'M'.

'N/M' is the piece of sausages for one critic, and i is the order of cutting.

Each sequence, if this value is natural number, decrease count.

 

Today's English

default : 기본값

critic : 평론가

think of A as B : A를 B로 간주하다

 

여담

이게 왜 골드?

'프로그래밍 문제풀이 > 백준 문제풀이' 카테고리의 다른 글

1388번: 바닥 장식  (0) 2022.11.19
1484번: 다이어트  (0) 2022.11.18
1111번: 색칠 1  (0) 2022.11.15
1548번: 부분 삼각 수열  (0) 2022.11.11
1106번: 호텔  (0) 2022.11.08
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
«   2025/06   »
1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30
글 보관함