일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 | 31 |
Tags
- JPA
- Java
- html
- hanghae99
- jQuery
- jenkins
- web
- bean
- 생명주기 콜백
- Stream
- Spring Security
- spring
- real time web
- session
- Project
- Anolog
- google oauth
- JWT
- Hibernate
- SseEmitter
- WIL
- DI
- programmers
- cookie
- python
- 항해99
- server send event
- oauth
- flask
- javascript
Archives
- Today
- Total
끄적끄적 코딩일지
[Programmers]부족한 금액 계산하기(난이도:★★★) 본문
https://programmers.co.kr/learn/courses/30/lessons/82612
코딩테스트 연습 - 부족한 금액 계산하기
새로 생긴 놀이기구는 인기가 매우 많아 줄이 끊이질 않습니다. 이 놀이기구의 원래 이용료는 price원 인데, 놀이기구를 N 번 째 이용한다면 원래 이용료의 N배를 받기로 하였습니다. 즉, 처음 이
programmers.co.kr
class Solution {
public long solution(int price, int money, int count) {
long totalPrice = calPect(count) * price;
long answer = totalPrice <= money? 0L : totalPrice-money;
return answer;
}
// num! 계산하기
public long calPect(int num){
long sum = 0L;
for(int i = 0; i< num;i++)
sum += ((long)i+1L);
return sum;
}
}
'알고리즘' 카테고리의 다른 글
[Programmers]나누어 떨어지는 숫자 배열(난이도:★★★) (0) | 2022.05.16 |
---|---|
[Programmers]2016년(난이도:★★★) (0) | 2022.05.16 |
[Programmers]x만큼 간격이 있는 n개의 숫자(난이도:★★) (0) | 2022.05.16 |
[Programmers]행렬의 덧셈(난이도:★★) (0) | 2022.05.16 |
[Programmers]휴대폰 번호 가리기(난이도:★★) (0) | 2022.05.16 |