https://school.programmers.co.kr/learn/courses/30/lessons/82612
프로그래머스
SW개발자를 위한 평가, 교육, 채용까지 Total Solution을 제공하는 개발자 성장을 위한 베이스캠프
programmers.co.kr
- 나의 코드
class Solution {
public long solution(int price, int money, int count) {
long answer = -1;
long total = 0;
for(int i=1; i<count+1; i++) {
total = total + (price*i);
}
if(money > total) {
answer = 0;
} else {
answer = total - money;
}
return answer;
}
}
'공부 > 알고리즘' 카테고리의 다른 글
숫자의 표현 (0) | 2025.01.04 |
---|---|
JadenCase 문자열 만들기 (0) | 2025.01.04 |
PCCP 기출문제 > 붕대 감기 (0) | 2024.11.22 |
PCCP 기출문제 > 동영상 재생기 (0) | 2024.11.18 |
2021 Dev-Matching: 웹 백엔드 개발자(상반기) > 다단계 칫솔 판매 (2) | 2024.11.09 |