Java/프로그래머스
[JAVA] 프로그래머스 - 피자 나눠 먹기(3)
쥬크버그
2024. 4. 19. 12:39
https://school.programmers.co.kr/learn/courses/30/lessons/120816
프로그래머스
코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요.
programmers.co.kr
정답
class Solution {
public int solution(int slice, int n) {
int answer = 0;
if(n%slice>0)
{
answer = n/slice+1;
}
else
{
answer = n/slice;
}
return answer;
}
}
다른 사람의 풀이
class Solution {
public int solution(int slice, int n) {
int answer = n/slice;
if(n%slice != 0){
answer++;
}
return answer;
}
}