File tree Expand file tree Collapse file tree
프로그래머스/0/120814. 피자 나눠 먹기 (1) Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ # [ level 0] 피자 나눠 먹기 (1) - 120814
2+
3+ [ 문제 링크] ( https://school.programmers.co.kr/learn/courses/30/lessons/120814 )
4+
5+ ### 성능 요약
6+
7+ 메모리: 89.8 MB, 시간: 0.02 ms
8+
9+ ### 구분
10+
11+ 코딩테스트 연습 > 코딩테스트 입문
12+
13+ ### 채점결과
14+
15+ 정확성: 100.0<br />합계: 100.0 / 100.0
16+
17+ ### 제출 일자
18+
19+ 2026년 04월 17일 15:29:10
20+
21+ ### 문제 설명
22+
23+ <p >머쓱이네 피자가게는 피자를 일곱 조각으로 잘라 줍니다. 피자를 나눠먹을 사람의 수 <code >n</code >이 주어질 때, 모든 사람이 피자를 한 조각 이상 먹기 위해 필요한 피자의 수를 return 하는 solution 함수를 완성해보세요.</p >
24+
25+ <hr >
26+
27+ <h5 >제한사항</h5 >
28+
29+ <ul >
30+ <li >1 ≤ <code >n</code > ≤ 100</li >
31+ </ul >
32+
33+ <hr >
34+
35+ <h5 >입출력 예</h5 >
36+ <table class =" table " >
37+ <thead><tr>
38+ <th >n</th >
39+ <th >result</th >
40+ </tr >
41+ </thead >
42+ <tbody><tr>
43+ <td >7</td >
44+ <td >1</td >
45+ </tr >
46+ <tr >
47+ <td >1</td >
48+ <td >1</td >
49+ </tr >
50+ <tr >
51+ <td >15</td >
52+ <td >3</td >
53+ </tr >
54+ </tbody >
55+ </table>
56+ <hr >
57+
58+ <h5 >입출력 예 설명</h5 >
59+
60+ <p >입출력 예 #1</p >
61+
62+ <ul >
63+ <li >7명이 최소 한 조각씩 먹기 위해서 최소 1판이 필요합니다.</li >
64+ </ul >
65+
66+ <p >입출력 예 #2</p >
67+
68+ <ul >
69+ <li >1명은 최소 한 조각을 먹기 위해 1판이 필요합니다.</li >
70+ </ul >
71+
72+ <p >입출력 예 #3</p >
73+
74+ <ul >
75+ <li >15명이 최소 한 조각씩 먹기 위해서 최소 3판이 필요합니다.</li >
76+ </ul >
77+
78+
79+ > 출처: 프로그래머스 코딩 테스트 연습, https://school.programmers.co.kr/learn/challenges
Original file line number Diff line number Diff line change 1+ class Solution {
2+ public int solution (int n ) {
3+ int answer = 0 ;
4+
5+ if (n %7 == 0 ) answer = n /7 ;
6+ else answer = n /7 +1 ;
7+
8+ return answer ;
9+ }
10+ }
You can’t perform that action at this time.
0 commit comments