๋ฌธ์
์ฝ๋
#include <iostream>
using namespace std;
long long solution(int price, int money, int count)
{
long long answer = -1,check=0;
long long original_price=price;
long long prices=(long long)price;
long long moneys=money;
while(check!=count){
moneys-=prices;
prices+=original_price;
check++;
}
if(moneys<0) answer=abs(moneys); //๊ธ์ก์ด ๋ถ์กฑํ ๊ฒฝ์ฐ
else answer=0; //๊ธ์ก์ด ๋ถ์กฑํ์ง ์์ ๊ฒฝ์ฐ
return answer;
}
๋๊ธ