Bomb Kirby Running
Cat Life - GT-K
82612번 부족한 금액 계산하기

2023. 3. 28. 09:21Programmers

코딩테스트 연습 - Level 1 - 부족한 금액 계산하기

https://programmers.co.kr/learn/courses/30/lessons/82612

using namespace std;

long long solution(int price, int money, int count)
{
    long long answer=money;    
    for(int i=1;i<=count;i++)
    {
        answer-=(i*price);
    }
    
    if(answer>=0)
    {
        return 0;
    }
    
    return answer*-1;
}