프로그래머스 132267 콜라 문제

Jmnote (토론 | 기여)님의 2023년 12월 2일 (토) 13:06 판
(차이) ← 이전 판 | 최신판 (차이) | 다음 판 → (차이)

1 개요[ | ]

프로그래머스 132267 콜라 문제

2 C++[ | ]

#include <string>
#include <vector>

using namespace std;

int solution(int a, int b, int n) {
    return (n > b ? n - b : 0) / (a - b) * b;
}
#include <string>
#include <vector>

using namespace std;

int solution(int a, int b, int n) {
    int answer = 0;
    while(n >= a) {
        int got = (n / a) * b;
        answer += got;
        n = got + (n % a);
    }
    return answer;
}
문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}