https://school.programmers.co.kr/learn/courses/30/lessons/82612
프로그래머스
코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요.
programmers.co.kr
기본적인 자바의 문법과 지식만으로도 충분히 풀 수 있는 문제입니다. 특정 유형 알고리즘 적용없이 문제의 로직대로 구현해주시면 됩니다.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | class Solution { public long solution(int price, int money, int count) { long answer = 0; long total_price = 0; for (int i = 1; i <= count; i++) { total_price += price * i; } if (total_price < money) { return 0; } else { answer = total_price - money; } return answer; } } | cs |