#include <iostream>
#include<cmath>
#include<ctime>
#include<string>
#include <iomanip>
#include <fstream>
using namespace std;
int main()
{
int firstprofit = 0;
int quantity = 0;
int q3 = 1;
//the targeted profit >> 50000
cout << "Enter the profit ";
int endProfit;
cin >> endProfit;
//first five quantity 1 * 1000+2 * 4000
firstprofit += 9000;
do
{
//the remaining quantity(q3) which is 50000(endProfit) - 9000(firstProfit) / 5
if (q3 == (endProfit - 9000) / 5)
firstprofit += q3 * 5;
else
q3++;
} while (firstprofit <= endProfit);
//the whole quantity
quantity += 1000 + 4000 + q3;
cout << quantity;
}
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter